如果我尝试挂载一个已经有文件的文件夹,linux 是否会给我一条错误消息或继续显示已挂载的文件系统和文件夹中已有的文件?
Gil*_*il' 118
在目录上挂载文件系统后/mount-point,您将无法再/mount-point直接访问其下的文件。它们仍然存在,但/mount-point现在指的是已挂载文件系统的根目录,而不是用作挂载点的目录,因此无法访问该目录的内容,至少无法以这种方式访问。例如:
# touch /mount-point/somefile
# ls /mount-point/somefile
/mount-point/somefile
# mount /dev/something /mount-point
# ls /mount-point/somefile
ls: cannot access /mount-point/somefile: No such file or directory
Run Code Online (Sandbox Code Playgroud)
有多种方法可以获得挂载的文件系统和已经存在的数据的合并视图,但是您需要一个称为联合文件系统的额外层。
在 Linux 下,有一种方法可以查看隐藏文件。您可以使用mount --bind获取挂载点所在文件系统的另一个视图。例如
mount --bind / /other-root-view
Run Code Online (Sandbox Code Playgroud)
您将看到根文件系统中的所有文件/other-root-view。
# cat /other-root-view/etc/hostname
darkstar
Run Code Online (Sandbox Code Playgroud)
特别是,/mount-point现在可以作为 访问/other-root-view/mount-point,并且由于/other-root-view/mount-point不是挂载点,您可以在那里看到其内容:
# ls /mount-point/somefile
ls: cannot access /mount-point/somefile: No such file or directory
# ls /other-root-view/mount-point/somefile
/other-root-view/mount-point/somefile
Run Code Online (Sandbox Code Playgroud)
Azz*_*Azz 38
它只会被挂载,文件消失,当文件夹被卸载时又回来了。
| 归档时间: |
|
| 查看次数: |
47319 次 |
| 最近记录: |