tags:

views:

837

answers:

2

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 "

+1  A: 

Hard links cannot span partitions or drives, so I would assume this would also be the case with NFS mounts.

Using soft-links instead should work with an NFS mount. I think it should work the same as soft linking between two separate partitions or physical drives.

tj111
I thought hard links cannot span disk partitions? Is that incorrect?
Brian
Hard links cannot span partitions. Soft links can.
Mike Cooper
Ahh sorry your correct, got hard link and soft link details mixed up. TGIF.
tj111
+2  A: 

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.

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

Mike Cooper
Hard links and soft links are both *pointers*, in a sense. The difference is that a soft link stores a textual representation of the file system path to the target, while a hard link (since it's just a directory entry) just stores the inode nubmer of the target, which must therefore be on the same filesystem as the directory the link itself is in.
Ian Clelland