如何在挂载之前访问挂载点目录的内容而不卸载?

Alp*_*ger 5 linux mount

我正在运行一个 Linux 服务器并且有一个加密分区。重新启动后,我手动登录服务器,输入密码并将其安装在/home.

/home有没有办法在不卸载加密分区的情况下访问挂载前的内容?

Dan*_*Sut 2

您可以使用--bind安装选项。

mkdir /mnt/tmproot
mount --bind / /mnt/tmproot
ls /home # Still shows contents of mounted /home partition
ls /mnt/tmproot/home # pre-mount contents of mountpoint /home dir
Run Code Online (Sandbox Code Playgroud)

此外,通过这种方式安装根分区将使您可以访问根分区中的安装点目录内容,而无需安装它们,同时还可以保留现有的安装。