NFS + Hard Links?

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

/root
    /A
    /B  <-NFS mount

      

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

+2


source to share


2 answers


Well, since it /B

is a separate filesystem (an NFS mounted filesystem), you cannot hard link it between and /A

because they are not on the same filesystem.



This is because a hard link does not make a copy of the data placed only by a copy of the pointer to that data, so they must be in the same "address space".

+6


source


It would be nice to first understand what a hard link is.

Typically on a unix-like system, the filename in a directory points to the inode number - essentially the number for the file. A "hard link" simply creates a different filename with the same inode number. You now have different names pointing to the same numbered file.



But note that there is actually no direct connection between the two names. The link is that Name1 and Name2 have an inode number set to 12756 - but you can't hold back and say that "this thing in my hand is a link between two files." These are just two records in the database that use the ID number. You can make a query (slow as you go through every file record on the system) for filenames that have an id, but this.

Thus, this does not mean that you need to create a "hard link between the two filesystems" - since the two filesystems have different numbering schemes (inode 1234 on system one and 1234 on the second system indicate completely different files), and the only thing is that you need to store is name + inodeNumber, there is nothing you can do.

+7


source







All Articles