此命令 - 在目录中以管理员(而非 root)身份运行
/volume2/Media/AllOurMedia/1 Our Pictures/Cataloged ( 3-5)
:
cp -l HL_Test.JPG /volume2/phototest/
得到这样的回应:
cp: cannot create hard link '/volume2/phototest/HL_Test.JPG' to 'HL_Test.JPG': Invalid cross-device link
我相信文件系统是相同的,但我无法解释文件/proc/self/mountinfo
、命令blkid
或命令的输出mount
。
符号链接对我的目的不起作用。
这是在 Linux 的 Synology NAS 版本上。
$ cat /etc/fstab
none /proc proc defaults 0 0
/dev/root / ext4 defaults 1 1
/dev/mapper/cachedev_1 /volume3 btrfs auto_reclaim_space,ssd,synoacl,relatime,nodev 0 0
/dev/mapper/cachedev_0 /volume4 btrfs auto_reclaim_space,ssd,synoacl,relatime,nodev 0 0
/dev/mapper/cachedev_2 /volume2 btrfs auto_reclaim_space,ssd,synoacl,relatime,nodev 0 0
/dev/mapper/cachedev_3 /volume1 btrfs auto_reclaim_space,ssd,synoacl,relatime,nodev 0 0
$ blkid
/dev/md0: LABEL="1.42.6-15090" UUID="87bac7d0-4cbf-4f26-8001-39a4f925cd09" TYPE="ext4"
/dev/mapper/cachedev_0: LABEL="2022.01.11-00:53:52 v42218" UUID="28db81a6-3f7f-42e8-9be7-dda711abf2d6" UUID_SUB="72557eeb-3c15-48c6-8b31-6c17f5c52304" TYPE="btrfs"
/dev/mapper/cachedev_1: LABEL="2022.01.11-00:26:16 v42218" UUID="7ed3fcf4-aeef-4a6a-ab91-968582b18bb7" UUID_SUB="b7219b75-ee21-480b-9bea-1104fdae19b8" TYPE="btrfs"
/dev/mapper/cachedev_2: LABEL="2017.05.30-11:24:09 v15101" UUID="df70890c-7fb8-4afa-a71e-f8805385a1aa" UUID_SUB="f1036abc-e9a3-49de-a972-c1590f3c83df" TYPE="btrfs"
/dev/mapper/cachedev_3: LABEL="2017.05.30-11:09:16 v15101" UUID="08a5afe9-d7f4-46f7-a342-2daea0babd51" UUID_SUB="85b94c31-6975-4db9-b5cb-931abe1a1152" TYPE="btrfs"
/dev/nvme0n1p1: UUID="b0885b18-6ade-6877-7086-234291332fff" UUID_SUB="e3f7fd80-152e-3cec-db39-c70ed0056da9" LABEL="NAS49:6" TYPE="linux_raid_member" PARTUUID="bff908a7-01"
/dev/nvme1n1p1: UUID="b0885b18-6ade-6877-7086-234291332fff" UUID_SUB="17cf5beb-e235-e4c0-62f2-932d993b01ab" LABEL="NAS49:6" TYPE="linux_raid_member" PARTUUID="982d332d-01"
/dev/sata1p1: UUID="df1a96d5-97de-e55a-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="94c2424b-8771-4263-8c76-44458f3ea4ad"
/dev/sata1p2: UUID="024f9ba3-13f9-b821-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="36f3de4f-418e-4f2e-85c2-998ae89d453a"
/dev/sata1p5: UUID="ddaba4d4-f65c-7322-2d60-826a27eaf650" UUID_SUB="6270eb2b-e08e-21c9-1212-b80ae2f40225" LABEL="NAS49:4" TYPE="linux_raid_member" PARTUUID="e36b8065-f5b6-43de-9735-c0f1d9ec264b"
/dev/sata2p1: UUID="df1a96d5-97de-e55a-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="d07fd25b-ea22-4214-99ad-26b14e4733ce"
/dev/sata2p2: UUID="024f9ba3-13f9-b821-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="139e801c-f998-4b71-9c41-0afbb330229f"
/dev/sata2p5: UUID="2300b63b-06a6-2fa5-4984-dc6908a14a29" UUID_SUB="41598730-05e5-5614-fb82-30d82443e1ae" LABEL="NAS49:5" TYPE="linux_raid_member" PARTUUID="8cde27db-286d-4325-8223-9d9ce21367b1"
/dev/sata3p1: UUID="df1a96d5-97de-e55a-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="6b5a60b3-cd53-470f-8567-312ce73e673f"
/dev/sata3p2: UUID="024f9ba3-13f9-b821-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="37750ba6-8645-4cda-acca-0c9ec717cfee"
/dev/sata3p5: UUID="4ca9422b-7156-5a45-a116-0114b098d99f" UUID_SUB="f42d1a26-ab90-4f26-2b1d-015167c29397" LABEL="NAS49:3" TYPE="linux_raid_member" PARTUUID="5a6ac30e-560c-498d-9e0d-c835a95df4a5"
/dev/sata4p1: UUID="df1a96d5-97de-e55a-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="929a3976-46f1-4d92-acd3-1e2831503d19"
/dev/sata4p2: UUID="024f9ba3-13f9-b821-3017-a5a8c86610be" TYPE="linux_raid_member" PARTUUID="147f96b0-ecbd-4050-b86b-3da2ab7cb687"
/dev/sata4p5: UUID="9f7e7e0e-a469-9617-f0db-e01aaf1e7025" UUID_SUB="9ed4fd01-ddbb-614a-e3e4-63bf59f5a872" LABEL="NAS49:2" TYPE="linux_raid_member" PARTUUID="e9025d5e-ae3d-4611-a8c4-6d5f46a39cdd"
/dev/zram0: UUID="c1cee02d-5500-49b8-a9b8-8fcabab4095f" TYPE="swap"
/dev/zram1: UUID="0976baee-86d6-4c08-a7c0-10d2d69a2224" TYPE="swap"
/dev/zram2: UUID="ee1c382c-3517-4648-a9ee-ba531625f8fc" TYPE="swap"
/dev/zram3: UUID="a4ba2853-91b4-4dd7-ad5d-f42e02ff52f6" TYPE="swap"
/dev/md1: UUID="9d0bcb90-72ba-4ebe-aaeb-50dfd83ba20e" TYPE="swap"
/dev/synoboot1: SEC_TYPE="msdos" UUID="10EE-589C" TYPE="vfat" PARTLABEL="EFI System" PARTUUID="90b655a2-5390-4d54-bb66-491e328704de"
/dev/synoboot2: UUID="45e5b07d-4783-4867-a369-f99c0cd1e610" TYPE="ext2" PARTLABEL="Linux filesystem" PARTUUID="93da2cbf-de5c-4a54-b9e2-90e634104aab"
/dev/md6: UUID="Jx6nfA-Oo12-jwv5-KkUp-4R7H-Hlsf-sXDuSf" TYPE="LVM2_member"
/dev/md4: UUID="mGLGr0-l6HF-C96v-wGhD-gXrE-2ibn-C3JyqZ" TYPE="LVM2_member"
/dev/md3: UUID="hu4FBb-d2yT-Whq1-NpRa-dIAz-tXz6-YIjRec" TYPE="LVM2_member"
/dev/md5: UUID="EqPEZc-22l2-CJp4-N8VH-y7c6-pLrH-TJ6ypJ" TYPE="LVM2_member"
/dev/md2: UUID="RvA1WH-mr2k-X2gG-ZnWD-uhY5-ZodO-1BnKkH" TYPE="LVM2_member"
/dev/loop0: LABEL="Windows" UUID="D4D0FCD1D0FCBAB6" TYPE="ntfs"
/dev/loop1: LABEL="LENOVO" UUID="22486CF1486CC4DF" TYPE="ntfs"
/dev/usb1p1: LABEL="New Volume" UUID="F61C55311C54EDDD" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="2c88cf31-2973-4e45-b729-d835b9d4ff75"
$ cat /proc/self/mountinfo
18 0 9:0 / / rw,noatime shared:1 - ext4 /dev/md0 rw,data=ordered
16 18 0:16 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw
17 18 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:8 - proc proc rw
19 18 0:6 / /dev rw,nosuid shared:9 - devtmpfs devtmpfs rw,size=1891376k,nr_inodes=472844,mode=755
20 16 0:12 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:3 - securityfs securityfs rw
21 19 0:17 / /dev/shm rw,nosuid,nodev shared:10 - tmpfs tmpfs rw
22 19 0:14 / /dev/pts rw,nosuid,noexec,relatime shared:11 - devpts devpts rw,gid=5,mode=620,ptmxmode=000
23 18 0:18 / /run rw,nodev shared:12 - tmpfs tmpfs rw,mode=755
24 16 0:19 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:4 - tmpfs tmpfs ro,mode=755
25 24 0:20 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:5 - cgroup cgroup rw,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
26 24 0:21 / /sys/fs/cgroup/synomonitor rw,nosuid,nodev,noexec,relatime shared:6 - cgroup cgroup rw,name=synomonitor
28 24 0:23 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,devices
29 24 0:24 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,cpuacct
30 24 0:25 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,blkio
31 24 0:26 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,memory
32 24 0:27 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,cpuset
33 24 0:28 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,cpu
34 24 0:29 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,freezer
35 18 0:30 / /tmp rw,nosuid,nodev,noexec shared:20 - tmpfs tmpfs rw
36 16 0:7 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:21 - debugfs debugfs rw
39 17 0:6 /bus/usb /proc/bus/usb rw,nosuid shared:9 - devtmpfs devtmpfs rw,size=1891376k,nr_inodes=472844,mode=755
63 16 0:33 / /sys/kernel/config rw,nosuid,nodev,noexec,relatime shared:22 - configfs configfs rw
71 18 0:35 /@syno /volume3 rw,nodev,relatime shared:23 - btrfs /dev/mapper/cachedev_1 rw,ssd,synoacl,space_cache=v2,auto_reclaim_space,metadata_ratio=50,block_group_cache_tree,syno_allocator,subvolid=256,subvol=/@syno
69 18 0:37 /@syno /volume4 rw,nodev,relatime shared:24 - btrfs /dev/mapper/cachedev_0 rw,ssd,synoacl,space_cache=v2,auto_reclaim_space,metadata_ratio=50,block_group_cache_tree,syno_allocator,subvolid=256,subvol=/@syno
65 18 0:34 /@syno /volume2 rw,nodev,relatime shared:25 - btrfs /dev/mapper/cachedev_2 rw,ssd,synoacl,nospace_cache,auto_reclaim_space,metadata_ratio=50,syno_allocator,subvolid=257,subvol=/@syno
66 18 0:36 /@syno /volume1 rw,nodev,relatime shared:26 - btrfs /dev/mapper/cachedev_3 rw,ssd,synoacl,nospace_cache,auto_reclaim_space,metadata_ratio=50,syno_allocator,subvolid=257,subvol=/@syno
76 18 0:33 / /config rw,nosuid,nodev,noexec,relatime shared:28 - configfs none rw
80 65 0:34 /@syno/@docker/btrfs /volume2/@docker/btrfs rw,nodev,relatime shared:25 - btrfs /dev/mapper/cachedev_2 rw,ssd,synoacl,nospace_cache,auto_reclaim_space,metadata_ratio=50,syno_allocator,subvolid=257,subvol=/@syno/@docker/btrfs
131 23 0:3 net:[4026532376] /run/docker/netns/c681364feff0 rw shared:27 - nsfs nsfs rw
27 66 0:22 / /volume1/BU/ActiveBackupData rw,nosuid,nodev,relatime shared:7 - fuse.synodedup-fused synodedup-fused rw,user_id=0,group_id=0,default_permissions,allow_other
$ mount
/dev/md0 on / type ext4 (rw,noatime,data=ordered)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1891376k,nr_inodes=472844,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nodev,mode=755)
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=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/synomonitor type cgroup (rw,nosuid,nodev,noexec,relatime,name=synomonitor)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /proc/bus/usb type devtmpfs (rw,nosuid,size=1891376k,nr_inodes=472844,mode=755)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
/dev/mapper/cachedev_1 on /volume3 type btrfs (rw,nodev,relatime,ssd,synoacl,space_cache=v2,auto_reclaim_space,metadata_ratio=50,block_group_cache_tree,syno_allocator,subvolid=256,subvol=/@syno)
/dev/mapper/cachedev_0 on /volume4 type btrfs (rw,nodev,relatime,ssd,synoacl,space_cache=v2,auto_reclaim_space,metadata_ratio=50,block_group_cache_tree,syno_allocator,subvolid=256,subvol=/@syno)
/dev/mapper/cachedev_2 on /volume2 type btrfs (rw,nodev,relatime,ssd,synoacl,nospace_cache,auto_reclaim_space,metadata_ratio=50,syno_allocator,subvolid=257,subvol=/@syno)
/dev/mapper/cachedev_3 on /volume1 type btrfs (rw,nodev,relatime,ssd,synoacl,nospace_cache,auto_reclaim_space,metadata_ratio=50,syno_allocator,subvolid=257,subvol=/@syno)
none on /config type configfs (rw,nosuid,nodev,noexec,relatime)
/dev/mapper/cachedev_2 on /volume2/@docker/btrfs type btrfs (rw,nodev,relatime,ssd,synoacl,nospace_cache,auto_reclaim_space,metadata_ratio=50,syno_allocator,subvolid=257,subvol=/@syno/@docker/btrfs)
nsfs on /run/docker/netns/c681364feff0 type nsfs (rw)
synodedup-fused on /volume1/BU/ActiveBackupData type fuse.synodedup-fused (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
$ df -h .
Filesystem Size Used Avail Use% Mounted on
- 5.3T 3.0T 2.3T 57% /volume2/Media
$ cd /volume2/phototest
$ df -h .
Filesystem Size Used Avail Use% Mounted on
- 5.3T 3.0T 2.3T 57% /volume2/phototest
答案1
解决方案1
鉴于您正在使用BTFS您将无法创建子卷硬链接。所以我认为你可以使用mount --bind
,但我不确定这是否适合你。我无法测试它,因为我没有BTFS子卷,但我希望这能起作用:
#Create the file 'HL_Test.JPG' under '/volume2/phototest/'
sudo touch /volume2/phototest/HL_Test.JPG
#Mount with --bind the original 'HL_Test.JPG' to the previous path
sudo mount --bind HL_Test.JPG /volume2/phototest/HL_Test.JPG
解决方案2
也许您应该尝试创建 asymbolic link
而不是hard link
.跨不同文件系统创建硬链接是不可能的。
如果您使用没有问题,symbolic links
那么您应该使用:
cp -s HL_Test.JPG /volume2/phototest/
#or If you get Permission Denied:
sudo cp -s HL_Test.JPG /volume2/phototest/
关于:
我相信文件系统是相同的
我相信您有/home
和/
位于不同的分区(可能具有相同的文件系统或不同的文件系统,例如ext4
、btrfs
、xfs
等)。尝试跑步df -T
。你应该得到这样的东西:
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p6 ext4 71670904 35050972 32933532 52% /
tmpfs tmpfs 3726644 12 3726632 1% /tmp
/dev/nvme0n1p7 ext4 118312816 43650512 68606164 39% /home
/dev/nvme0n1p1 vfat 262144 78348 183796 30% /boot/efi
tmpfs tmpfs 745328 112 745216 1% /run/user/1000
正如您在上面看到的,我有/home
和/
位于不同的分区上。因此,如果我尝试cp -l
跨两个文件系统使用,我将无法做到这一点。
顺便说一句,我假设您的文件HL_Test.JPG
位于/home/
分区/文件系统下。但也许你有HL_Test.JPG
另一个文件系统,除了/
.