我买了一个新硬盘,并搬到那里。我点击了以下链接:https://www.howtogeek.com/442101/how-to-move-your-linux-home-directory-to-another-hard-drive/。
但是新的硬盘在重启时不断卸载,我总是必须运行mount -a
命令。
新的硬盘是/dev/sda1
。
blkid /dev/sda1
给出/dev/sda1: UUID="7c34e1a9-bf29-4b8d-aaf7-e955b647575d" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="ba042bba-01"
。
这是我的/etc/fstab
文件:
#
# /etc/fstab
# Created by anaconda on Thu Feb 18 09:11:13 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=621d28d8-16de-44e8-b733-1dab40daea02 / btrfs subvol=root,x-systemd.device-timeout=0 0 0
UUID=03011415-2410-443a-a923-ce1154ea8ea3 /boot ext4 defaults 1 2
UUID=3D2C-76FF /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=621d28d8-16de-44e8-b733-1dab40daea02 /home btrfs subvol=home,x-systemd.device-timeout=0 0 0
#UUID=7c34e1a9-bf29-4b8d-aaf7-e955b647575d /home btrfs subvol=home,x-systemd.device-timeout=0 0 0
/dev/sda1 /home ext4 rw,seclabel,relatime 0 0
这是我的/proc/mounts
文件:
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=4096k,nr_inodes=131072,mode=755,inode64 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev,inode64 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,size=3187704k,nr_inodes=819200,mode=755,inode64 0 0
cgroup2 /sys/fs/cgroup cgroup2 rw,seclabel,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
/dev/mapper/luks-76241767-67a8-4d40-aafc-25eb50a2e22a / btrfs rw,seclabel,relatime,ssd,space_cache,subvolid=257,subvol=/root 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,nosuid,noexec,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=31,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=18047 0 0
mqueue /dev/mqueue mqueue rw,seclabel,nosuid,nodev,noexec,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
tracefs /sys/kernel/tracing tracefs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /tmp tmpfs rw,seclabel,nosuid,nodev,nr_inodes=1048576,inode64 0 0
/dev/mapper/luks-76241767-67a8-4d40-aafc-25eb50a2e22a /home btrfs rw,seclabel,relatime,ssd,space_cache,subvolid=256,subvol=/home 0 0
/dev/loop2 /var/lib/snapd/snap/core18/2785 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop4 /var/lib/snapd/snap/core18/2721 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop3 /var/lib/snapd/snap/core/15511 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop0 /var/lib/snapd/snap/core/14946 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop7 /var/lib/snapd/snap/core22/607 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop1 /var/lib/snapd/snap/atomify/153 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop5 /var/lib/snapd/snap/core20/1852 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop8 /var/lib/snapd/snap/core22/817 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop9 /var/lib/snapd/snap/gnome-3-28-1804/198 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop6 /var/lib/snapd/snap/core20/1974 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop10 /var/lib/snapd/snap/gnome-3-38-2004/119 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop11 /var/lib/snapd/snap/gnome-3-38-2004/137 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop12 /var/lib/snapd/snap/gnome-42-2204/120 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop15 /var/lib/snapd/snap/gtk-common-themes/1535 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop13 /var/lib/snapd/snap/gnome-42-2204/87 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop16 /var/lib/snapd/snap/rubymine/334 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop18 /var/lib/snapd/snap/signal-desktop/428 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop14 /var/lib/snapd/snap/gtk-common-themes/1534 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop17 /var/lib/snapd/snap/rubymine/351 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop19 /var/lib/snapd/snap/signal-desktop/493 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop20 /var/lib/snapd/snap/snapd/17950 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop22 /var/lib/snapd/snap/xournalpp/69 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop21 /var/lib/snapd/snap/snapd/19457 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop23 /var/lib/snapd/snap/xournalpp/82 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/nvme0n1p2 /boot ext4 rw,seclabel,relatime 0 0
/dev/nvme0n1p1 /boot/efi vfat rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/user/1000 tmpfs rw,seclabel,nosuid,nodev,relatime,size=1593852k,nr_inodes=398463,mode=700,uid=1000,gid=1000,inode64 0 0
portal /run/user/1000/doc fuse.portal rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
/dev/sda1 /home ext4 rw,seclabel,relatime 0 0
这是我的/etc/mtab
文件:
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=4096k,nr_inodes=131072,mode=755,inode64 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev,inode64 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,size=3187704k,nr_inodes=819200,mode=755,inode64 0 0
cgroup2 /sys/fs/cgroup cgroup2 rw,seclabel,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
/dev/mapper/luks-76241767-67a8-4d40-aafc-25eb50a2e22a / btrfs rw,seclabel,relatime,ssd,space_cache,subvolid=257,subvol=/root 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,nosuid,noexec,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=31,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=18047 0 0
mqueue /dev/mqueue mqueue rw,seclabel,nosuid,nodev,noexec,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
tracefs /sys/kernel/tracing tracefs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /tmp tmpfs rw,seclabel,nosuid,nodev,nr_inodes=1048576,inode64 0 0
/dev/mapper/luks-76241767-67a8-4d40-aafc-25eb50a2e22a /home btrfs rw,seclabel,relatime,ssd,space_cache,subvolid=256,subvol=/home 0 0
/dev/loop2 /var/lib/snapd/snap/core18/2785 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop4 /var/lib/snapd/snap/core18/2721 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop3 /var/lib/snapd/snap/core/15511 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop0 /var/lib/snapd/snap/core/14946 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop7 /var/lib/snapd/snap/core22/607 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop1 /var/lib/snapd/snap/atomify/153 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop5 /var/lib/snapd/snap/core20/1852 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop8 /var/lib/snapd/snap/core22/817 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop9 /var/lib/snapd/snap/gnome-3-28-1804/198 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop6 /var/lib/snapd/snap/core20/1974 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop10 /var/lib/snapd/snap/gnome-3-38-2004/119 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop11 /var/lib/snapd/snap/gnome-3-38-2004/137 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop12 /var/lib/snapd/snap/gnome-42-2204/120 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop15 /var/lib/snapd/snap/gtk-common-themes/1535 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop13 /var/lib/snapd/snap/gnome-42-2204/87 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop16 /var/lib/snapd/snap/rubymine/334 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop18 /var/lib/snapd/snap/signal-desktop/428 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop14 /var/lib/snapd/snap/gtk-common-themes/1534 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop17 /var/lib/snapd/snap/rubymine/351 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop19 /var/lib/snapd/snap/signal-desktop/493 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop20 /var/lib/snapd/snap/snapd/17950 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop22 /var/lib/snapd/snap/xournalpp/69 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop21 /var/lib/snapd/snap/snapd/19457 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/loop23 /var/lib/snapd/snap/xournalpp/82 squashfs ro,context=system_u:object_r:snappy_snap_t:s0,nodev,relatime,errors=continue 0 0
/dev/nvme0n1p2 /boot ext4 rw,seclabel,relatime 0 0
/dev/nvme0n1p1 /boot/efi vfat rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/user/1000 tmpfs rw,seclabel,nosuid,nodev,relatime,size=1593852k,nr_inodes=398463,mode=700,uid=1000,gid=1000,inode64 0 0
portal /run/user/1000/doc fuse.portal rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
/dev/sda1 /home ext4 rw,seclabel,relatime 0 0
答案1
您已经注释掉了 ftab 文件中用于挂载驱动器的行(以 UUID=7c34e1a9-bf29-4b8d-aaf7-e955b647575d... 开头的行),该行指的是您的新磁盘。
该条目也引用了 btrfs,但磁盘是 ext4。您可能需要更改条目以反映这一点。
答案2
我对这里发生的事情最好的猜测是……
看起来您的原始系统正在使用 btrfs。但如果您按照该链接的说明操作,您的新驱动器将被格式化为 ext4。混合这样的文件系统在理论上可能可行,但也可能需要额外的配置更新。特别是因为看起来 fstab 的旧行已为主目录配置了一个 btrfs 子卷:
UUID=621d28d8-16de-44e8-b733-1dab40daea02 /home btrfs subvol=home,x-systemd.device-timeout=0 0 0
此外,我认为您不能将多个块设备挂载到同一个文件系统点。 中只有一个条目/etc/fstab
可以挂载到/home
。
例如,你的 fstab 看起来应该是这样的:
#
# /etc/fstab
# Created by anaconda on Thu Feb 18 09:11:13 2021
# Updated by user on 2023-08-02
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=621d28d8-16de-44e8-b733-1dab40daea02 / btrfs subvol=root,x-systemd.device-timeout=0 0 0
UUID=03011415-2410-443a-a923-ce1154ea8ea3 /boot ext4 defaults 1 2
UUID=3D2C-76FF /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=7c34e1a9-bf29-4b8d-aaf7-e955b647575d /home ext4 rw,seclabel,relatime 0 0
#
# older entries below
#
# original /home entry
#UUID=621d28d8-16de-44e8-b733-1dab40daea02 /home btrfs subvol=home,x-systemd.device-timeout=0 0 0
#
# likely wrong vfstype in column three (and thus wrong options in column four)
#UUID=7c34e1a9-bf29-4b8d-aaf7-e955b647575d /home btrfs subvol=home,x-systemd.device-timeout=0 0 0
#
# Probably correct, but with obsolete /dev/sdX syntax. Use UUID.
#/dev/sda1 /home ext4 rw,seclabel,relatime 0 0
答案3
存在权限问题。我已重置主分区挂载点及其目录的安全标签。
后su
:
restorecon -v /home /home/*