Question

I know it is a condition of hard links that they cannot span filesystems. Does this apply to NFS mounts? Given the following directory structure, would I be able to create a hard link in directory A that points to a file in directory B?

/root
    /A
    /B  <-NFS mount

For example, I'd like to run ln /root/B/file.txt /root/A/linkedfile.txt

Was it helpful?

Solution

Well, since /B is a separate file system (a mounted NFS file system) you cannot make a hard link between it and /A, because they are not on the same file system.

It's because a hardlink doesn't make a copy of the data put only a copy of the pointer to that data, so they have to be in the same "address space".

OTHER TIPS

It'd be a good idea to first understand exactly what a hard link is.

Usually on a unix-like system, a filename in a directory points to an inode number - essentially a number for a file. A "hard link" is just creating another filename with that same inode number. Now you have to different names that point to the same numbered file.

But notice that there's not really a direct connection between those two names. The relationship is that Name1 and Name2 both have their inode number set to 12756 - but there's nothing you can hold up and say "this thing in my hand is the link between two files". They're just two database entries that share an id number. You can do a query (slow, since you're walking through every file entry on the system) for filenames that share an id number, but that's it.

So it doesn't mean anything to create a "hard link between two filesystems" - since two filesystems have different numbering schemes (inode 1234 on system one, and 1234 on system two, point to completely different files), and the only thing you have to store is a name+inodeNumber, there's nothing to be done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top