NFS + Hard Links?

Brian picture Brian · Aug 28, 2009 · Viewed 18.4k times · Source

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

Answer

Mike Cooper picture Mike Cooper · Aug 28, 2009

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".