Filesystems
在 xfs 上,為什麼我不能硬連結到 /tmp/,當我的 fstab 指示 tmp 在同一個分區上時,給出錯誤“無效的跨設備連結”?
我的錯誤:
ln "99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7e279afaf90cec961233.png" /home/anon/foo.png # ^ works fine ^ ln "99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7e279afaf90cec961233.png" /tmp/foo.png ln: failed to create hard link '/tmp/foo.png' => '99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7e279afaf90cec961233.png': Invalid cross-device link
這裡的答案是:https ://unix.stackexchange.com/a/108558/79280
您的 /home 目錄很可能與 /root 目錄不在同一個分區上。
您可以使用 cat /etc/fstab 輕鬆檢查這一點,不能在不同分區之間創建硬連結,只有符號連結可以。
但是,如您所見:
cat /etc/fstab 1 ✘ # /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> UUID=A189-F750 /boot/efi vfat umask=0077 0 2 UUID=11bc9e0c-1727-4df7-b357-0fc11f66444a swap swap defaults,noatime 0 0 UUID=acc6e22f-a4d8-4766-bf57-ae13838bd5a8 / xfs defaults,noatime 0 1
這表明
/tmp/
並且/home/
應該在安裝點上。這可能是一個錯誤,還是/tmp/
這裡有我不知道的特殊行為?還; 這是特定於 xfs 的嗎?我沒有一台機器可以在 ext4 上測試它。
編輯:
使用評論中推薦的命令。
cat /proc/self/mountinfo 1 ✘ 24 29 0:22 / /proc rw,nosuid,nodev,noexec,relatime shared:5 - proc proc rw 25 29 0:23 / /sys rw,nosuid,nodev,noexec,relatime shared:6 - sysfs sys rw 26 29 0:5 / /dev rw,nosuid,relatime shared:2 - devtmpfs dev rw,size=8009848k,nr_inodes=2002462,mode=755,inode64 27 29 0:24 / /run rw,nosuid,nodev,relatime shared:12 - tmpfs run rw,mode=755,inode64 28 25 0:25 / /sys/firmware/efi/efivars rw,nosuid,nodev,noexec,relatime shared:7 - efivarfs efivarfs rw 29 1 259:3 / / rw,noatime shared:1 - xfs /dev/nvme0n1p3 rw,attr2,inode64,logbufs=8,logbsize=32k,noquota 30 25 0:6 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw 31 26 0:26 / /dev/shm rw,nosuid,nodev shared:3 - tmpfs tmpfs rw,inode64 32 26 0:27 / /dev/pts rw,nosuid,noexec,relatime shared:4 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 33 25 0:28 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:9 - cgroup2 cgroup2 rw,nsdelegate,memory_recursiveprot 34 25 0:29 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:10 - pstore pstore rw 35 25 0:30 / /sys/fs/bpf rw,nosuid,nodev,noexec,relatime shared:11 - bpf none rw,mode=700 36 24 0:31 / /proc/sys/fs/binfmt_misc rw,relatime shared:13 - autofs systemd-1 rw,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=1148 37 26 0:21 / /dev/mqueue rw,nosuid,nodev,noexec,relatime shared:14 - mqueue mqueue rw 38 26 0:32 / /dev/hugepages rw,relatime shared:15 - hugetlbfs hugetlbfs rw,pagesize=2M 39 25 0:7 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:16 - debugfs debugfs rw 40 25 0:11 / /sys/kernel/tracing rw,nosuid,nodev,noexec,relatime shared:17 - tracefs tracefs rw 41 25 0:33 / /sys/kernel/config rw,nosuid,nodev,noexec,relatime shared:18 - configfs configfs rw 42 36 0:34 / /proc/sys/fs/binfmt_misc rw,nosuid,nodev,noexec,relatime shared:19 - binfmt_misc binfmt_misc rw 44 25 0:35 / /sys/fs/fuse/connections rw,nosuid,nodev,noexec,relatime shared:20 - fusectl fusectl rw 142 29 0:37 / /tmp rw,nosuid,nodev shared:63 - tmpfs tmpfs rw,size=8019684k,nr_inodes=409600,inode64 149 29 259:1 / /boot/efi rw,relatime shared:77 - vfat /dev/nvme0n1p1 rw,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 445 27 0:43 / /run/user/1000 rw,nosuid,nodev,relatime shared:242 - tmpfs tmpfs rw,size=1603936k,nr_inodes=400984,mode=700,uid=1000,gid=1001,inode64 514 445 0:45 / /run/user/1000/gvfs rw,nosuid,nodev,relatime shared:278 - fuse.gvfsd-fuse gvfsd-fuse rw,user_id=1000,group_id=1001 531 445 0:46 / /run/user/1000/doc rw,nosuid,nodev,relatime shared:297 - fuse.portal portal rw,user_id=1000,group_id=1001
和
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) dev on /dev type devtmpfs (rw,nosuid,relatime,size=8009848k,nr_inodes=2002462,mode=755,inode64) run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755,inode64) efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime) /dev/nvme0n1p3 on / type xfs (rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=1148) mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M) debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime) tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime) configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime) fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime) tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=8019684k,nr_inodes=409600,inode64) /dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1603936k,nr_inodes=400984,mode=700,uid=1000,gid=1001,inode64) gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1001) portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1001)
您的數據表明這
/tmp
是一個單獨的文件系統(tmpfs):142 29 0:37 / /tmp rw,nosuid,nodev shared:63 - tmpfs tmpfs rw,size=8019684k,nr_inodes=409600,inode64
您可以通過以下方式禁用此行為:
sudo systemctl mask tmp.mount
在這種情況下,
/tmp
將屬於您的根文件系統。你必須重新啟動。