Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 626
Dancrumb Avatar asked Dec 22 '10 13:12

Dancrumb


People also ask

How do I enable local remote symbolic links?

Remote to remote symbolic links are enabled. If you also need to enable remote to local link evaluation, you can substitute R2R:1 with R2L:1 in the set behavior command.

Does NFS support symlinks?

Symbolic links are both useful and confusing when used with NFS-mounted filesystems. They can be used to "shape" a filesystem arbitrarily, giving the system administrator freedom to organize filesystems and pathnames in convenient ways.

How does a symbolic link work?

A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.


3 Answers

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
like image 160
dietbuddha Avatar answered Sep 17 '22 13:09

dietbuddha


The link correctly points to /alpha/foo, but that doesn't exist on your machine. If you mount /alpha, the link will work.

like image 38
robert Avatar answered Sep 21 '22 13:09

robert


You might be able to use the sshfs utility to do what you want to do. This will let you mount a filesystem on a remote computer, on your local one. Here's a reference to how to do this: https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh

like image 30
mml_sw Avatar answered Sep 17 '22 13:09

mml_sw