macos OS X 挂载本地目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1081485/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:15:21  来源:igfitidea点击:

OS X mount local directory

macosunixmount

提问by

Is it possible to mount a local directory into another one? Using Perforce, I want to do something equivalent to symlinking a directory, but in a way that fools it into thinking it's really just another directory in the project.

是否可以将本地目录挂载到另一个目录中?使用 Perforce,我想做一些相当于对目录进行符号链接的事情,但以一种愚弄它的方式让它认为它实际上只是项目中的另一个目录。

I would like to do something like:

我想做类似的事情:

mount /foo/bar /home/foo/bar

Is this possible, and if so what options do I need to give it?

这可能吗,如果可以,我需要提供哪些选项?

采纳答案by Stobor

bindfsseems like what you're after...

bindfs似乎是你所追求的......

回答by ennuikiller

You can only mount different filesystems under the directory tree. You may be able to achieve what you're looking to do by hard linking the directories. OS X allows hard linking directories and to perforce it would like like different directories

您只能在目录树下挂载不同的文件系统。您可以通过硬链接目录来实现您想要做的事情。OS X 允许硬链接目录并强制它想要不同的目录

回答by ignis

mount localhost:/path1 /path2

will use NFS.

将使用 NFS。

There is a lot of things that may go wrong with NFS, it would be insane to handle them in this answer, better ask on apple.stackexchange.comand read man mount_nfs(8).

NFS 可能有很多问题,在这个答案中处理它们会很疯狂,最好在apple.stackexchange.com询问并阅读man mount_nfs(8)

回答by Dan Walters

The BSD (and thus Darwin/OSX) method of achieving this is nullfs. It's not in a standard build of OS X, but perhaps it's possible to build from source if you have the time to play around with it.

实现这一点的 BSD(以及 Darwin/OSX)方法是nullfs。它不在 OS X 的标准构建中,但如果您有时间尝试使用它,也许可以从源代码构建。

回答by David

To make a hard link from one directory to another, run:

要建立从一个目录到另一个目录的硬链接,请运行:

$ ln /foo/bar /home/foo/bar

It is important to note that from the OS's perspective, both links are treated equally. You can delete /foo/barand /home/foo/barwill remain a valid reference to the data on disk.

需要注意的是,从操作系统的角度来看,这两个链接被同等对待。您可以删除/foo/bar/home/foo/bar保留对磁盘上数据的有效引用。