Limits for hard links? (Invalid cross-device link)

I’m trying to link up qBittorrent and Sonarr et al. My filesystem datasets used to look like this:

Main
|
|————configs
|    |
|    |————qbittorrent
|         |
|         |————appdata
|         |————downloads
|
|————media
     |
     |————Movies
     |————Shows

When I tried to manually add hard links for a show not found by my Prowlarr indexer (i.e. a link from Main/media/Shows directory to Main/configs/qbittorrent/downloads), I got the aforementioned “Invalid cross-device link” error. I tried linking it to the Main/media/Movies directory, and that worked.

So I reconfigured all my datasets, and now I’m getting the same error, and I can’t even make the Shows-to-Movies hard link anymore. How can I set it up so that this will work? Right now the datasets look like this:

Main
|
|————configs
|    |
|    |————qbittorrent
|         |
|         |————appdata
|
|————media
     |
     |————Servarr
          |
          |————downloads
          |————Movies
          |————Shows

It might be relevant that there are more directories beneath what’s shown. Here’s one of the hard links I’m trying to make at the moment (I’d like to stress that this particular episode of Wagon Train is, to the best of my knowledge, in the public domain!):

ln '/mnt/Main/media/Servarr/downloads/Manual/Shows/wagon-train/s05e18 the dr. denker story.mp4' '/mnt/Main/media/Servarr/Shows/Wagon Train/Season 5/s05e18 the dr. denker story.mp4'

Are you sure those are directories and not datasets?

zfs list -t fs -r -o name Main
1 Like

They were all datasets. I remade everything beneath Main/media/Servarr as regular directories and not datasets, and the links work just fine now. Thanks!

And it looks like when I thought it was working before even when it was across datasets, that was a false positive, since when I tried again it appeared as a broken link in the File Browser app.

The main thing to remember is that hard links work only within a single filesystem, not across filesystems. If you need to need to go across filesystem boundaries, use symlinks.

The down side of symlinks is that if you remove the target you will get a broken link.

With hard links it is not possible to get a broken link as all directory entries are just references to the underlying data; all hard links are created equal (there is no “master” or “original” as such).

Is that so? I tried creating symlinks when the TARGET and LINK_NAME were on different filesystems, and I had the same false positive situation, i.e. it would appear to work from the console but the file browser would show the file as a broken link. But I’ll keep those points in mind :saluting_face:.

That can happen if the software reading the link is chroot’d or the link creator and consumer are using different mount points such that the link does not resolve to the correct location. Either are possible in this situation and I’m not sure what the browser is doing here.

1 Like