Debian
重新安裝 Debian 8 後如何更改主分區?
我有**/分區和使用者的主**分區。我一直喜歡它,因為我不需要在重新安裝後再次複製所有使用者文件。
今天我在我的電腦上重新安裝了 Debian 8 Jessie,但安裝程序沒有問我是否有以前的主分區。
我發現我的舊主分區安裝在**/media/roby/0a2a038c-6525-4db4-9404-4b6a6cc31318 中**(使用者文件夾位於該文件夾中,編號很少)。
我想讓所有使用者都在**/home 中**而不移動文件。
這是 mount 的輸出:
roby@roby-laptop:~$ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=1427783,mode=755) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,relatime,size=2287848k,mode=755) /dev/sda8 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) mqueue on /dev/mqueue type mqueue (rw,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) debugfs on /sys/kernel/debug type debugfs (rw,relatime) fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime) rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1143924k,mode=700,uid=1000,gid=1000) gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000) /dev/sda10 on /media/roby/0a2a038c-6525-4db4-9404-4b6a6cc31318 type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
這是 /etc/fstab 的內容:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda8 during installation UUID=0d993ab9-95c8-467c-a29e-7faf55edbf0c / ext4 errors=remount-ro 0 1 # swap was on /dev/sda9 during installation UUID=c333a585-606f-4299-a51a-491a873f2024 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
這是 fdisk -l 的輸出:
roby@roby-laptop:~$ sudo fdisk -l Disco /dev/sda: 931,5 GiB, 1000204886016 bytes, 1953525168 sectores Unidades: sectores de 1 * 512 = 512 bytes Tamaño de sector (lógico/físico): 512 bytes / 512 bytes Tamaño de E/S (mínimo/óptimo): 512 bytes / 512 bytes Tipo de etiqueta de disco: gpt Identificador del disco: 7BFA0BD1-AAD9-44BC-9E39-02C19702ABA0 Device Start End Sectors Size Type /dev/sda1 2048 1026047 1024000 500M EFI System /dev/sda2 1026048 1107967 81920 40M desconocido /dev/sda3 1107968 1370111 262144 128M Microsoft reserved /dev/sda4 1370112 2906111 1536000 750M Windows recovery environment /dev/sda5 2906112 318377983 315471872 150,4G Microsoft basic data /dev/sda6 1936297984 1953523119 17225136 8,2G Windows recovery environment /dev/sda7 318377984 318380031 2048 1M BIOS boot /dev/sda8 318380032 384786431 66406400 31,7G Linux filesystem /dev/sda9 384786432 408223743 23437312 11,2G Linux swap /dev/sda10 408223744 1936297983 1528074240 728,7G Microsoft basic data Las entradas de la tabla de particiones no están en el orden del disco.
這是 blkid 的輸出:
roby@roby-laptop:~$ sudo blkid /dev/sda1: LABEL="ESP" UUID="0C2C-B5E9" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="24239fe3-8042-42d8-99df-d806b3b4807a" /dev/sda2: LABEL="DIAGS" UUID="ACCB-CD97" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="2ebf1341-b877-450d-9e40-3e3501e94c09" /dev/sda4: LABEL="WINRETOOLS" UUID="082ECDC32ECDA9D0" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="3a25a975-26a8-49be-baba-dd7f8a954ddd" /dev/sda5: LABEL="OS" UUID="F84AD3034AD2BD96" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="ca58cbd5-6ee8-49f4-8621-7481a3139e7e" /dev/sda6: LABEL="PBR Image" UUID="26FE2ACEFE2A95D9" TYPE="ntfs" PARTLABEL="Microsoft recovery partition" PARTUUID="9b0eb66c-9325-47b3-9b6f-7ff65fad6201" /dev/sda8: LABEL="raiz" UUID="0d993ab9-95c8-467c-a29e-7faf55edbf0c" TYPE="ext4" PARTUUID="463ac6e5-03c6-40c5-b3a6-8f6e7273d17c" /dev/sda9: UUID="c333a585-606f-4299-a51a-491a873f2024" TYPE="swap" PARTLABEL="particion_swap" PARTUUID="91fbb9a7-4ca9-4f7c-aa4e-4cc8e7ca28b6" /dev/sda10: UUID="0a2a038c-6525-4db4-9404-4b6a6cc31318" TYPE="ext4" PARTLABEL="particion_home" PARTUUID="737accdd-913a-4c71-bb54-403473f3f1a9" /dev/sda3: PARTLABEL="Microsoft reserved partition" PARTUUID="cff2cf6d-6d50-483b-a270-b67c6cfa366a" /dev/sda7: PARTUUID="1df154d8-dfa5-4c08-ad79-0115d84a45cd"
確保在執行以下命令之前備份所有重要文件
新盒子上的使用者需要與舊盒子具有相同的 UID,否則您需要在每個目錄上執行 chown 來解決此問題
- 首先,您需要找到舊主分區的 UUID
sudo blkid
跑步
blkid
會給出這樣的結果:/dev/sdc1: UUID="5cb14ab6-9e40-4a11-b0c5-02941e4c31dd" TYPE="swap" PARTUUID="972688be-01" /dev/sda1: UUID="c9717f86-3774-4135-9b81-14b7559f5944" TYPE="ext3" PARTUUID="6bb0af62-01" /dev/sdb1: UUID="5ac8e363-a519-4482-989d-12b2df7156b7" TYPE="ext3" PARTUUID="b416bc44-01"
- 根據您的輸出辨識與您的舊主分區匹配的 UUID 它是“/dev/sda10”
- 在 /etc/fstab 的末尾添加以下行
UUID=0a2a038c-6525-4db4-9404-4b6a6cc31318 /home ext4 defaults 0 2
- 重啟
重啟後您目前的 /home 將不可用 請在重啟前備份其中的所有重要文件
- 要在失敗的情況下回滾,請刪除添加到 fstab 的行並重新啟動