绑定挂载内的绑定挂载

绑定挂载内的绑定挂载

我正在尝试将一个文件绑定挂载到另一个文件上,然后删除现在隐藏的文件。我正在尝试按如下方式解决此问题:

folder1# echo a > a
folder1# echo b > b
folder1# mount -o bind a b
folder1# cat b
a #All good - the bind mount worked
folder1# cd ..
# mount -o bind folder1 folder2
# cd folder2
folder2# cat b
b #OK, as expected
folder2# unlink b
rm: cannot remove 'b': Device or resource busy

我想b从实际磁盘中删除,但保持绑定挂载处于a活动状态。

所以如果它有效的话,它会像

# cd folder2
folder2# cat b
b
folder2# unlink b
folder2# cat b
cat: error: No such file or directory
folder2# cd ../folder1
folder1# cat b
a #The bind mount is still active

我怎样才能让Linux按照我想要的方式运行?

相关内容