0

This command - run as Admin (not Root) in directory /volume2/Media/AllOurMedia/1 Our Pictures/Cataloged ( 3-5):

cp -l HL_Test.JPG /volume2/phototest/

got this response:

cp: cannot create hard link '/volume2/phototest/HL_Test.JPG' to 'HL_Test.JPG': Invalid cross-device link

I believe the file system is the same, but I can’t interpret the output of the file /proc/self/mountinfo, the command blkid or the command mount.

Symbolic links will not work for my purposes.

This is on the Synology NAS version of Linux.

$ 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
    

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
Bones
  • 1
  • "but I can’t interpret the output […]" – We neither, until you [edit] the question and post the exact output. – Kamil Maciorowski Nov 21 '22 at 05:03
  • @KamilMaciorowski fair :) – Bones Nov 21 '22 at 09:47
  • 1
    /dev/mapper/cachedev_2 on /volume2 type btrfs. AFAIK in Btrfs an attempt to create a hardlink across subvolumes is rejected as "invalid cross-device link", even if under a single mountpoint. This is probably what happens here. A reflink is what you can create. This is not an answer because I don't know the question. Is your question "why?", "how to make it work?, "what can I do instead?" or what? – Kamil Maciorowski Nov 21 '22 at 11:00
  • My question is how to make it work Source file is on /volume2/Media/AllOurMedia/1 Our Pictures/Cataloged ( 3-5) Destination is on /volume2/phototest/

    /volume2/Media/ is one "Synology FIleshare" /volume2/phototest/ is a seperate "Synology FIleshare"

    The source files will often get edited and occationally get MOVED - hence why symbolic link is not seen as an option

    – Bones Nov 21 '22 at 13:39

1 Answers1

0

Solution 1
Given that you are using btrfs subvolumes you won't be able to create hard links. So I think you could use mount --bind but I'm not really sure if this will work for you. I cannot test it because I don't have btrfs subvolumes but I hope this works:

#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

Solution 2
Maybe you should try to create a symbolic link and not a hard link. Creating hard links across different filesystems is not possible.

If you have no problem with using symbolic links then you should use:

cp -s HL_Test.JPG /volume2/phototest/

#or If you get Permission Denied: sudo cp -s HL_Test.JPG /volume2/phototest/

About:

I believe the file system is the same

What I believe is that you have /home and / in different partitions (maybe with the same filesystem or not, such as ext4,btrfs, xfs, etc.). Try running df -T. You should get something like this:

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

As you can see above I have /home and / on different partitions. So If I try using cp -l across both filesystems I won't be able to do it.

By the way, I'm assuming that your file HL_Test.JPG is under /home/ partition/filesystem. But maybe you have HL_Test.JPG on another filesystem except /.

  • the file - HL_Test.JPG is in the folder wher the cp -l command is executed - ie "/volume2/Media/AllOurMedia/1 Our Pictures/Cataloged ( 3-5)"

    df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/md0 ext4 2385528 1885856 380888 84% / devtmpfs devtmpfs 1891376 0 1891376 0% /dev

    – Bones Nov 21 '22 at 09:57
  • tmpfs tmpfs 1928360 124 1928236 1% /dev/shm tmpfs tmpfs 1928360 24540 1903820 2% /run tmpfs tmpfs 1928360 0 1928360 0% /sys/fs/cgroup tmpfs tmpfs 1928360 1680 1926680 1% /tmp /dev/mapper/cachedev_1 btrfs 2807499328 2183478844 624020484 78% /volume3 /dev/mapper/cachedev_0 btrfs 2807499328 2125574476 681924852 76% /volume4 – Bones Nov 21 '22 at 10:02
  • /dev/mapper/cachedev_2 btrfs 5621463124 3176947944 2444515180 57% /volume2 /dev/mapper/cachedev_3 btrfs 7496824260 4715057764 2781766496 63% /volume1 /dev/usb1p1 fuseblk.ntfs 9766402044 6547275012 3219127032 68% /volumeUSB2/usbshare – Bones Nov 21 '22 at 10:02
  • @Bones as Kamil Maciorowski said, you won't be able to create hard links on btrfs subvolumes. You will have to create symbolic links. – Edgar Magallon Nov 21 '22 at 22:08
  • @Bones I updated the answer with another possible solution by using mount --bind – Edgar Magallon Nov 21 '22 at 22:17
  • 1
  • thanks for the explicit commands - ran them worked as you expected.
  • i now see why hard links wont work - thansk All I will now work through how weel i can make --bind work. I have 30,000 pictures i want to have in two directory structures - one for the Photo Management tool - and one for the Presentation tool. this can do it - just need to decide if it is managable/sustainable

    Appreciate resonses and patience chaps

    – Bones Nov 22 '22 at 10:48
  • @Bones nice! And about mount --bind you can also bind directories. So if your 30,000 pictures is under some directory you can bind it instead of bind every file. – Edgar Magallon Nov 22 '22 at 20:55