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

จัดการดิสก์อย่างมืออาชีพเมื่อย้ายจาก Windows ไป Linux

วันนี้ผมอยากหยุดจาก Template บทความ Windows-to-Linux ล่าสุด ที่โฟกัส Show how to install, configure และใช้ Programs หลากหลาย ที่ออกแบบ/ตั้งใจสำหรับ Windows เท่านั้น ผ่าน Frameworks อย่าง WINE วันนี้เราจะพูดถึง juicy topic: Disk และ Drive management

นอกจาก Applications ยังมี Data ที่ Critical ทุกอย่าง กลายเป็น Extra complicated เมื่อพิจารณา Cardinal differences ระหว่าง Windows และ Linux Windows ใช้ NTFS Data organized ใน Drives (C:, D:, ฯลฯ) Linux เก็บทุกอย่างใต้ Filesystem tree เดียว (Root, /) ใช้ Filesystem formats ต่างๆ (ext4) แม้ Handle NTFS ได้ ดังนั้น ถ้าพยายาม Move stuff over จะทำยังไง? Tutorial นี้เป็น Neat suggestion สำหรับคนมองหา Order, Simplicity และ Clarity

Preliminary reading

Guide นี้ไม่สามารถอยู่ใน Isolation ได้ มี Hard laws of physics ที่ต้องปฏิบัติ First: หากคุณไม่รู้อะไรเลยเกี่ยว Disk/Drive management, Filesystems ฯลฯ Article นี้ไม่ใช่สำหรับคุณจริงๆ ต้องมี Basic foundation ของ Principles นี้ Let's be realistic Article นี้สำหรับ Nerds แต่มี Practical experience ใน Linux น้อย (เพียงแค่ยัง)

Articles ของผมที่ควรอ่านก่อน:

GParted partitioning software tutorial
The ultimate Linux guide for Windows newbies

Same same but different

ตอนนี้รู้ Lingo และ Technical details มา Discuss Scenario: สมมติคุณมี Windows machine สอง Physical disks และรวม 5 Disk partitions Layout ดังนี้:

  • C:\ drive - Windows และ Core OS files, Program files, User data
  • D:\ drive - Games installation (รวม Steam)
  • E:\ drive - User's data (Files, Movies, Music, Documents) NOT stored under My Documents
  • F:\ drive (บน Disk ที่สอง) - Backup; User data คัดลอกทุกสัปดาห์
  • H:\ drive (บน Disk ที่สอง) - Unimportant stuff (Downloads, Raw videos, ฯลฯ)

Owner สนใจย้ายไป Linux จะทำ: Repartition disks - Shrink H:\ drive สร้าง Partitions ใหม่ใน Freed space ติดตั้ง Linux distro ตรงนั้น ตอนนี้ Dual-boot system Power on/Restart เห็น Menu เลือก Linux หรือ Windows

จัดการดิสก์อย่างมืออาชีพเมื่อย้ายจาก Windows ไป Linux

เห็นได้ว่า Outline นี้และ Scenario คล้ายๆ ใน Dual-boot articles ต่างๆ ของผม (Linked above, Windows 7 & Ubuntu, Windows 7 & CentOS) ให้ Reference point สำหรับ Adventure คล้ายกัน และ Sense ของ Initial differences ใน Disk management ใน Linux

ตอนนี้ User มี System สอง OS แต่มี Problem: Bulk of data ยังอยู่ใน Windows และ/หรือ Saved/Kept บน Windows drives NTFS formatted คำถาม:

  • User เข้าถึง Windows data ได้ไหม?
  • User Modify Windows data ได้ไหม?
  • User Migrate data จาก Windows drives ไป Native Linux filesystems บน Partitions อื่นได้ไหม?
  • User Convert NTFS filesystems เป็น Native Linux ones ได้ไหม?

มาตอบกันเถอะ!

  • Linux อ่าน NTFS filesystems ได้โดยไม่มี Issues ใหญ่ Distributions ส่วนใหญ่ Support นี้ Natively
  • Linux เขียน NTFS ได้ แต่ไม่ใช่ทุก Distros มี Capability Out of the box Solution: Install NTFS-3g utility ให้ Functionality ที่จำเป็น เช่น Red Hat distros (CentOS, AlmaLinux, Rocky Linux): sudo dnf install ntfs-3g ntfsprogs
  • User Migrate data ได้ แต่ใน Scenario ข้างต้น อาจไม่มีพอพื้นที่บน Linux partitions ใหม่ สำหรับ Windows stuff ทั้งหมด รวม Data, Backups, และอื่นๆ
  • Conversion of filesystems เป็น Risky operation นำไปสู่ Data loss ไม่ควรทำโดยไม่มี Complete, Verifiable data backup แต่ถ้ามี Backup อยู่แล้ว 不如 Format partitions ด้วย Native filesystem และ Copy data over

Disk management opacity

Solution สำหรับ Scarcity of disk space และ/หรือ Easy data migration path คือ Present Windows data ภายใน Linux system แบบ Easy to discern และ Allow practical data backups อธิบาย: ใน Linux Paths ทั้งหมด Resolve ไป Root (/) เช่น /home/igor เป็น Mount point สำหรับ Home directory ของ user "igor" แต่ Physical mapping ของ Directory นั้นสามารถอยู่ที่ไหนก็ได้ Different partition, Different disk, Even different system (Network) เช่น:

  • Root filesystem (/) เป็น Mount point สำหรับ /dev/sda1 (Partition แรกบน Disk แรก)
  • /home/igor เป็น Directory ไม่ใช่ Separate mount point Data อยู่บน /dev/sda1 (Disk เดียวกัน)
  • Alternatively /home/igor อาจ Resolve ไป /dev/sda2 หรือ /dev/sdc7 หรือ NFS, CIFS, Samba shares

หมายถึง หาก User Mount Windows drives จะ Presented ใน Linux as part of Single root filesystem และไม่ Necessarily discernible จาก Locations/Paths อื่นๆ อีกครั้ง:

Linux systems ส่วนใหญ่ Mount Removable, External หรือ Non-Linux devices ใต้ /run/media หรือ /media หากเห็นสอง Directories ใต้ Locations นี้ ไม่ว่าจะชื่ออะไร คุณไม่ Necessarily สามารถ Distinguish ได้ หนึ่งอาจเป็น Internal Windows NTFS partition อีกอันเป็น FAT32 USB drive

Solution, แล้ว

Work around ปัญหานี้ ผมใช้ Method นี้:

  • สร้าง Top-level directory ใต้ Root เรียกว่า drives (/drives)
  • ภายใน สร้าง Directories เป็น Mount points สำหรับ Windows drives ใช้ Letters เป็น Identifiers เช่น /drives/C สำหรับ C:\, /drives/E สำหรับ E:\, ฯลฯ
  • สร้าง Permanent mount rules สำหรับ Windows drives ใต้ /etc/fstab (รายละเอียดเร็วๆ นี้) หมายถึงเมื่อ Boot Windows drives จะ Mounted as writable devices และ Presented as directories ใต้ Top-level /drives location

Method นี้ Ensure อะไร?

Benefits หลายอย่าง:

  • Clear และ Visible separation ระหว่าง Linux-only/pure Linux paths และ Windows paths
  • ไม่ Mix all non-Linux devices/partitions ใต้ Generic directories
  • Running backup scripts ให้แน่ใจว่า Copy/Backup แค่สิ่งที่ต้องการ หาก Full backup Linux system และมี Filesystems/drives อื่นๆ Mounted ไม่จำเป็นต้อง Include ทั้งหมดใน Backup และไม่ต้อง Account for every "Unknown" path

นี่คือวิธีทำ

ตาม Example ก่อนหน้า First step: Figure out Linux "Sees" Internal hard disks และ Identifies Windows drives ยังต้อง Expertise นิดหน่อย ใช้ Command-line tools อย่าง fdisk Output list of devices และ partitions สมมติว่า:

  • /dev/sda1 - C:\ drive
  • /dev/sda2 - D:\ drive
  • /dev/sda3 - E:\ drive
  • /dev/sdb1 - F:\ drive
  • /dev/sdb2 - H:\ drive
  • /dev/sdb3 - Linux root (/)
  • /dev/sdb4 - Linux swap
  • /dev/sdb5 - Linux home (/home)

สร้าง /drives top-level path และ directories ใต้ (สำหรับ Windows drives only):

sudo mkdir /drives
sudo mkdir /drives/C
sudo mkdir /drives/D
...

As root หรือ sudo สร้าง Backup /etc/fstab แล้ว Edit ใน Text editor (nano):

sudo cp /etc/fstab /home/"your user"/fstab-backup
sudo nano /etc/fstab

ใน Text editor เพิ่ม Mount points สำหรับ Windows drives:

/dev/sda1 /drives/C ntfs-3g defaults,locale=utf8 0 0
/dev/sda2 /drives/D ntfs-3g defaults,locale=utf8 0 0
...

เรามีอะไรบ้าง?

  • ระบุ Device/Partition จริงที่จะ Mount
  • ระบุ Mount point
  • ระบุ Filesystem - ใช้ ntfs-3g driver (ให้ Read/write access)
  • ระบุ Mount options - Simple ด้วย Defaults + UTF8 encoding
  • ตั้ง Last two fields (dump และ fsck) เป็น 0 Exclude จาก Classic Linux operations

ตัวอย่างจริงจาก System ของผม:

# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/nvme0n1p5 during installation
# /boot/efi was on /dev/nvme0n1p1 during installation

UUID=7f4087e7-e572-44fd-a4a1-7489099937a0 / ext4 errors=remount-ro 0 1
UUID=C05A-951D /boot/efi vfat umask=0077 0 1
/swapfile none swap sw 0 0
/dev/nvme0n1p3 /drives/C ntfs-3g defaults,locale=utf8 0 0

สาม Entries แรกที่ไม่ Comment เป็น Mount entries สำหรับ Linux filesystems รวมถึง Root (/), /boot/efi (Required on UEFI systems VFAT filesystem) และ Swapfile แทน Swap partition

Entry ที่สี่คือ Addition ของ Windows drive โปรดสังเกต Device identifier ไม่ใช่ /dev/sdaXY แต่เป็น /dev/nvmeXnYp3 เพราะ System มี NVMe hard disk Linux Identify ต่างจาก IDE/SATA/SCSI devices แต่ Practical purposes Notation เหมือนกัน

สิ่งที่เรามี: First (0) NVMe bus, First (1) device, Third (3) partition อ้างอิง Guides ของผม Hard disk management และ GRUB tutorial Notation สำหรับ Devices และ Partitions ต่างกัน ดังนั้น Example ข้างต้น Mount Windows partition (Effectively Third partition on NVMe disk) ใต้ /drives/C

ไม่ต้อง Reboot เพื่อดู Effect แค่ Remount everything:

sudo mount -a

ตอนนี้ Windows drives Mounted ไปที่ Paths ตรงกัน และเห็น Data ขั้นตอนต่อไป: ทำให้ Mounted data ใช้งานและเข้าถึงง่ายขึ้น

File manager และ Windows drives

หากต้องการใช้ Data จาก GUI (ไม่ใช่ Command line) ทำ Trick นี้:

  • สร้าง Symbolic links ใน Home directory ไปยัง Mounted drives
  • โดยเฉพาะ Symbolically link แต่ละ Drive (Letter) ไปยัง Folder ที่มี Meaningful identifier เช่น Windows drive names

ln -s /drives/C ~/Windows

Command ข้างต้นสร้าง Symbolic link ใน Home directory Windows จะ Map ไป /drives/C ซึ่งเป็น Mount point ของ C:\ drive ดังนั้น Click ที่ Folder Windows ใน Linux file manager จะเห็น Contents ของ Windows drive

จัดการดิสก์อย่างมืออาชีพเมื่อย้ายจาก Windows ไป Linux

ไปอีกขั้น สร้าง Shortcuts ไปยัง Drives ใน Plasma desktop environment เพิ่ม Shortcuts ไป Sidebar Windows map ไป /drives/C Games map ไป /drives/D Data map ไป /drives/E ฯลฯ Next step: เพิ่ม Backup tasks เข้า Flow แต่เป็น Topic สำหรับ Tutorial อื่น

สรุป

Tutorial ของผมไม่ใช่ Holy grail ของ Data management ไกลมาก แต่ Provide Elegant suggestions สำหรับ Common problems ที่คนอาจเจอเมื่อย้าย Windows ไป Linux Present Windows data ใน Visible, Intuitive manner ไม่รวม Destructive operations อนุญาต Convenient backups และ Data separation และเสนอให้คนที่เคย Windows workflow ปรับตัวเข้าสู่ Environment ใหม่อย่างช้าๆ โดยไม่ Compromise Familiar clues หรือ Established workflows

ด้วย Windows-only drives Mounted ใน Own path Symbolic links ให้ Convenient access ผ่าน GUI tools และ Logical mapping คุณตอนนี้ควรมี Good, Solid foundation สำหรับ Migration ขั้นตอนต่อไป: ทำให้ Important data Backed up เพราะ Data without backups คือ Tragedy waiting to happen เราจะครอบคลุมนั้น และ Practical day-to-day tips อื่นๆ ใน Follow-up articles ตอนนี้ คิดนิดหน่อยเกี่ยวกับ Data scheme ที่ Outline ข้างต้น และ Stay tuned สำหรับ Additional program setup guides See you soon.

Cheers.