Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Linux

วิธี Mount Windows Share Folder บน Linux

วิธี Mount Windows Share Folder บน Linux

Linux และ Windows systems มีความแตกต่างใหญ่ มี file systems และ protocols ที่ต่างกัน การ share ไฟล์ระหว่างกันยาก โดยเฉพาะเพราะใช้ sharing protocols ที่ต่างกัน แต่ไม่ได้หมายความว่า impossible ที่จะ mount Windows share folder บน Linux ตามมาดูวิธีกัน

Share Windows Folder ของคุณ

ก่อนทำอะไร ต้องแน่ใจว่า Windows ตั้งค่าให้ allow networking file sharing อย่างถูกต้อง

เพื่อ enable บน Windows ให้คลิกขวาที่ network icon ใน notifications area ของ Windows taskbar จากนี้คลิก "Open Network & Internet Settings"

วิธี Mount Windows Share Folder บน Linux

ใต้ category "Status" คลิก "Sharing options"

วิธี Mount Windows Share Folder บน Linux

ใน Windows sharing options menu ให้แน่ใจว่า "Turn on network discovery" และ "Turn on file and printer sharing" enabled คลิก radio buttons ถัดจากทั้งสองเพื่อยืนยัน

วิธี Mount Windows Share Folder บน Linux

คลิก "Save changes" เพื่อบันทึก settings เมื่อเสร็จ เปิด Windows File Explorer หาโฟลเดอร์ที่อยาก share กับ Linux PC

คลิกขวาโฟลเดอร์ คลิก "Properties"

วิธี Mount Windows Share Folder บน Linux

ใน folder properties คลิก tab "Sharing" แล้วคลิก "Advanced Sharing" คลิก enable checkbox "Share this folder" แล้วคลิก "Permissions"

วิธี Mount Windows Share Folder บน Linux

ใต้ section "Permissions" ตั้ง control rights สำหรับโฟลเดอร์ โดย default Windows ให้ read-only access

หากอยากให้ทุกคน read/write โฟลเดอร์ คลิก "Allow" สำหรับ permissions set "Full Control" ตั้ง permissions ให้เหมาะกับความต้องการ

วิธี Mount Windows Share Folder บน Linux

เมื่อเสร็จ คลิก "OK" สามครั้งเพื่อปิด dialog boxes ทั้งหมด

โฟลเดอร์ของคุณควร shared บน network แล้ว พร้อมเข้าถึงจาก Linux PC

ติดตั้ง CIFS-utils

ขึ้นอยู่กับ Linux distribution อาจ mount Windows-shared folder อัตโนมัติใน file explorer ของ distribution ได้

แต่สิ่งนี้อาจไม่ทำงานถูกต้อง วิธีปลอดภัยที่สุดคือใช้ package CIFS-utils และ mount folder ผ่าน Linux terminal

นี่ช่วยให้ Linux machines เข้าถึง SMB file shares ที่ Windows PCs ใช้

วิธี Mount Windows Share Folder บน Linux

ติดตั้ง CIFS-utils เปิดเทอร์มินัลใหม่ สำหรับ Ubuntu และ Debian-based distributions พิมพ์:

sudo apt install cifs-utils

สำหรับ Arch users พิมพ์:

pacman -S cifs-utils

ติดตั้งเสร็จ สามารถ mount Windows share folder จาก Linux terminal ได้

Mount Windows SMB Share บน Linux

ต้องสร้าง mount directory ก่อน mount Windows SMB-shared folder บน Linux นี่คือที่ที่ Linux จะ mirror เนื้อหาของ shared folder

เปิดเทอร์มินัลพิมพ์:

sudo mkdir /mnt/share

เมื่อสร้างแล้ว พิมพ์ต่อไปนี้:

sudo mount.cifs //Windows/SharedFolder /mnt/share -o user=account

แทนที่ "Windows" ด้วย IP address หรือ hostname ของ Windows PC และ "SharedFolder" ด้วยชื่อ shared folder สำหรับ username แทนที่ "account" ด้วย Windows username หรือ full Microsoft account email

วิธี Mount Windows Share Folder บน Linux

จะถูกขอให้ใส่ Windows password ก่อน mount เสร็จ พิมพ์แล้วกด Enter หากข้อมูลถูกต้อง Windows folder ควร mounted และเข้าถึงได้ในโฟลเดอร์ที่สร้าง

Share Files ระหว่าง Linux และ Windows ใน Dual Boot

Share files ระหว่าง Windows และ Linux ทำงานดีเมื่อ mount shared folder ระหว่างสองอุปกรณ์ แต่ยัง share files ได้กับ dual boot setup ไหม? Linux และ Windows มี file systems แยกกัน Linux มักใช้ Ext4 Windows ใช้ NTFS และทำงานกับ FAT32 ได้ นี่ไม่ได้หมายความว่า impossible ที่จะเห็นและ share files

ต้องการ compatible Windows system build 20211 หรือสูงกว่า และ resources อื่นๆ นิดหน่อย ทำให้ทำงานได้ ไม่ต้องกังวล ทุกอย่างฟรี คู่มือนี้เดินทางผ่านแต่ละขั้นตอน รวมถึงวิธีอ่านและ share files ระหว่าง Windows และ Linux

คำถามที่พบบ่อย

1. ทำไมได้ syntax error ตอนพยายาม mount folder ใน Linux?

อาจมี error เล็กน้อยในคำสั่งใน terminal window หรือชื่อโฟลเดอร์มี space Spaces ไม่ได้มาถูกต้องใน syntax เสมอไป แทนที่จะ recognize คำสั่งเป็น full folder name ระบบเห็นสองสิ่งที่ไม่เกี่ยวข้อง

หลีกเลี่ยงโดยวางชื่อใน quotes เช่น Shared Folder จะกลายเป็น "Shared Folder" หรือ rename โฟลเดอร์ Windows 10 ให้รวมคำหรือมี dash ระหว่างคำ

2. Mount shared folder ได้หากใช้ VirtualBox?

ได้ กระบวนการควรทำงานเหมือนกัน สามารถ share devices เช่น USB drives ได้ด้วย

3. Mount guest, network, หรือ password protected folders ได้ไหม?

ได้ แต่เนื่องจากไม่ได้ใช้ main Windows 10 account ต้องปรับ syntax เล็กน้อย และหาก mount network folder ต้องการ server หรือ machine name ด้วย

แม้คู่มือนี้ใช้กับ Ubuntu ควรทำงานกับ major Linux distros อื่นๆ ได้ มี syntax สำหรับ scenarios ต่างๆ โดยสมมติว่าเสร็จทุกขั้นตอน (ยกเว้น mount สุดท้าย) ข้างต้น

4. ทำไมมีแค่ read access สำหรับ shared folder?

หากอยาก store files ใน shared folder จาก Linux ต้องแน่ใจว่ามี full read/write access ใน Windows หาก Windows user account มีแค่ read permission นี่คือ permission เดียวที่จะมีจาก Linux เช่นกัน ต้องเปลี่ยน account permissions จากภายใน Windows 10 สำหรับบริษัท ต้องขอ IT admin ทำให้

5. ทำไมการเปลี่ยนแปลงโฟลเดอร์ไม่แสดง?

หากเปลี่ยน permissions ของโฟลเดอร์ อาจไม่แสดงทันทีใน Linux ต้อง remount folder เพื่อให้ changes take effect

sudo mount -a

ใช้คำสั่งข้างต้น remount shared folders ใดๆ ควรทำให้ทำงานตามที่คาด หากมี random glitches remounting มักแก้ได้

สรุป

การ mount Windows และ Linux shared folders ให้ความอิสระเข้าถึงไฟล์สำคัญ ไม่ว่าจะ OS ใด SMB protocol ได้รับการ support ดีบน Linux จึงไม่ควรยากที่จะเข้าถึง Windows files และ folders ต่อไปหลังติดตั้ง CIFS-utils package

หากชอบใช้ single system นี่คือ 5 Linux distros สำหรับ Windows users ที่ดีที่สุด