目前, /
有共享挂载传播:
# findmnt -o TARGET,PROPAGATION / TARGET PROPAGATION / shared
我正在考虑将其更改为private
以使mount --move
可以在/mnt
和/media
下mount --move
文件系统上运行。
(我想用mount --move
而不是unsafe umount --lazy
)
没有/
没有private
, mount --move
会抱怨这样的事情:
# mount --move /mnt/mountpoint /mnt/moved mount: /mnt/moved: bad option; moving a mount residing under a shared mount is unsupported.
为什么/
默认shared
?
什么是改变/
成为private
的含义?
传播标志由systemd
改变。 从man 7 mount_namespaces
:
systemd(1)在系统启动时自动将所有安装点重新挂载为MS_SHARED。 因此,在大多数现代系统中,默认传播types实际上是MS_SHARED。
从https://github.com/systemd/systemd/blob/master/src/core/mount-setup.c#L406
/* Mark the root directory as shared in regards to mount propagation. The kernel defaults to "private", but we * think it makes more sense to have a default of "shared" so that nspawn and the container tools work out of * the box. If specific setups need other settings they can reset the propagation mode to private if * needed. Note that we set this only when we are invoked directly by the kernel. If we are invoked by a * container manager we assume the container manager knows what it is doing (for example, because it set up * some directories with different propagation modes). */ if (detect_container() <= 0) if (mount(NULL, "/", NULL, MS_REC|MS_SHARED, NULL) < 0)
其含义取决于您的特定用例。 我认为大多数项目将继续工作。 但是,重新启动后,您的更改将被覆盖。
您可以在Lennart Poettering的评论中阅读更多内容https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739593
这是它的一部分:
b)如果你修补systemd回到MS_PRIVATE作为根目录,你禁止传播到容器,没有人可以selectjoin它的特定命名空间。
优点:你不需要修补那些目前假定根目录是MS_PRIVATE的程序,也不会解除关联。
缺点:对于那些切换到MS_SHARED for /的应用程序仍然是打破的。 因此,您只能覆盖人们不会混淆的用例。 你打破了人们希望传播到这个地方的用例。