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

6

21

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

Galbreath answered 22/12, 2010 at 13:46 Comment(0)
M
20

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
Myel answered 22/12, 2010 at 17:23 Comment(0)
O
2

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

Offshore answered 22/12, 2010 at 13:50 Comment(0)
E
2

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

Emetic answered 18/12, 2014 at 19:29 Comment(0)
H
1

soft symbol link's content is a path string, it doesn't know anything about how you mount filesystems. In your case, you can mount /alpha and /beta on B with sample path of A. But strongly suggest don't cross link between network system, that's hard to maintain.

Hoogh answered 22/12, 2010 at 17:2 Comment(0)
C
0

You will need to mount /alpha in your machine in order to have the link to work.

Coprophilous answered 22/12, 2010 at 15:58 Comment(0)
B
-1

sounds like what you really want is a hard link. its another pointer to the same data in the filesystem, so to really delete that file and free up that disk space, you have to delete all hard links to it.

some scripts and tools can get confused by them.

Bruns answered 17/2, 2013 at 1:48 Comment(3)
Your answer doesn't relate to the user's question about linking between multiple file systems.Reborn
@mattgately: yes it does. pixel did not express it very clearly, but the hard link is the absolute solution. Possibly not one the OP is ready to use for whatever (valid) reason, but definitely a valid solution to accessing the required file directly from /beta without having to mount /alpha.Langlauf
I could be mistaken, but I believe that the question is about files on two different file systems, so hard links are not even an option in this scenario.Reborn

© 2022 - 2024 — McMap. All rights reserved.