I know hard links can't cross filesystems, but trying to link files via bind mounts that physically live on the same filesystem fails as well. I detailed things below to visualize it better, but the TLDR of my question is why is ln
treating the mounted directories as though they live separately?
Basically, copying files into a share folder would be best-served with hardlinks so I'm not duplicating space:
mymedia/
├─ share/
│ ├─ pics/
│ │ ├─ pic2.tif
│ ├─ vids/
│ │ ├─ vid1.mov
├─ homevid/
│ ├─ vid1.mov
│ ├─ vid2.mov
│ ├─ vid3.mov
├─ homepic/
│ ├─ pic1.tif
│ ├─ pic2.tif
├─ training/
mymedia/share
is on one drive (Media1), whereas homepic
is on Media2 and homevid
on Media3. The two folders in share
are mounted from Media2/Media3. This is from fstab:
/dev/disk/by-uuid/UUID_1 /mnt/Media1 auto 0 0
/dev/disk/by-uuid/UUID_2 /mnt/Media2 auto 0 0
/dev/disk/by-uuid/UUID_3 /mnt/Media3 auto 0 0
/mnt/Media1 /mnt/mymedia none bind
/mnt/Media2/homepic /mnt/mymedia/homepic none bind
/mnt/Media2/share /mnt/mymedia/share/pics none bind
/mnt/Media3/homevid /mnt/mymedia/homevid none bind
/mnt/Media3/share /mnt/mymedia/share/vids none bind
I can create the link while using the "real" path, like so: ln /mnt/Media2/homepic/pic2.tif /mnt/Media2/share/
, and see the new file in both directories; stat
confirms the inode is the same for the files, as well as same device:
Path |
Device |
/mnt/Media2/homepic |
831h/2097d |
/mnt/Media2/share |
831h/2097d |
/mnt/mymedia/homepic |
831h/2097d |
/mnt/mymedia/share/pics |
831h/2097d |
/mnt/mymedia/training |
821h/2081d |
Unfortunately, using the bind mounts would be way better for my workflow (this fails): ln /mnt/mymedia/homepic/pic1.tif /mnt/mymedia/share/pics/pic2.tif
What am I missing?