How do you make symbolic links work with a remote mount?

Dancrumb picture Dancrumb · Dec 22, 2010 · Viewed 60.4k times · Source

I have two servers, A and B

A has two filesystems, /alpha and /beta

I have a symbolic link:

ln -s /alpha/foo /beta/bar

Such that:

lrwxrwxrwx 1 root    root           70 Dec 22 13:32 /beta/bar -> /alpha/foo

Next, I mount /beta, remotely on B via an NFS mount

The link no longer works.

Is there a way to achieve this. I'd like to be able to access A:/alpha/foo on server B, but I want to be able to do it via the /beta/bar symbolic link.

Do I need to modify my mount, or my link? Or am I trying to achieve the impossible?

UPDATE

I should have added: 'without mounting /alpha to server B'. In short, I would like the symbolic link to be followed to the actual file in question whenever server B accesses /beta/bar

Answer

dietbuddha picture dietbuddha · Dec 22, 2010

Soft links only contain a path to another file on the local machine. You cannot reference a file that is not accessible on the local filesystem(s).

Options:

  • Don't use soft links, copy the file
  • Cross-linking (almost always a bad idea)
  • Reorganize/redo whatever imposes the file access requirement