Linux 你如何使符号链接与远程安装一起工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4509772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you make symbolic links work with a remote mount?
提问by Dancrumb
I have two servers, A and B
我有两台服务器,A 和 B
A has two filesystems, /alpha and /beta
A 有两个文件系统,/alpha 和 /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
接下来,我通过 NFS 挂载在 B 上远程挂载 /beta
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.
有没有办法实现这一目标。我希望能够访问服务器 B 上的 A:/alpha/foo,但我希望能够通过 /beta/bar 符号链接进行访问。
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 actualfile in question whenever server B accesses /beta/bar
我应该补充说:'没有将 /alpha 安装到服务器 B'。简而言之,当服务器 B 访问 /beta/bar 时,我希望符号链接被跟踪到相关的实际文件
采纳答案by dietbuddha
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
- 不要使用软链接,复制文件
- 交联(几乎总是一个坏主意)
- 重新组织/重做强加文件访问要求的任何内容
回答by robert
The link correctly points to /alpha/foo
, but that doesn't exist on your machine. If you mount /alpha
, the link will work.
该链接正确指向/alpha/foo
,但您的机器上不存在该链接。如果您 mount /alpha
,则链接将起作用。
回答by dirac3000
You will need to mount /alpha
in your machine in order to have the link to work.
您需要安装/alpha
在您的机器上才能使链接正常工作。
回答by Huang F. Lei
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.
软符号链接的内容是一个路径字符串,它不知道您如何挂载文件系统。在您的情况下,您可以使用 A 的示例路径在 B 上挂载 /alpha 和 /beta。但强烈建议不要在网络系统之间进行交叉链接,这很难维护。
回答by pixel
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.
一些脚本和工具可能会被它们混淆。
回答by mml_sw
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
您或许可以使用 sshfs 实用程序来完成您想做的事情。这将允许您在本地计算机上的远程计算机上安装文件系统。以下是如何执行此操作的参考:https: //www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh