These flags to the mount
command are advanced features which modify the way bind-mounts work. They also have the same effects on mount-namespaces, and this is sometimes used by systemd
to allow a process to have its own private mounts.
The --make-unbindable
flag prevents any later bind-mounting of either part or the whole of a mount:
mount --make-unbindable /master
#Both of these will fail
mount --rbind /master /slave
mount --rbind /master/subdir /slave
The other flags effect how changes to submounts within a mount are synchronized between future bind-mounts and namespaces. The use of --rbind
instead of --bind
is still needed to recursively share all existing submounts with the bind mount, except those made unbindable as above.
Like --bind
, all these flags also have variants with an r
prefix which are recursively applied to all contained mounts.
The --make-[r]shared
flag (the initial state with systemd) enables synchronisation between a master mount and future copies. By example, for an existing mount at /master
, both master-submount
and slave-submount
will be mounted under both /master
and /slave
:
mount --make-rshared /master
mount --rbind /master /slave
mount /dev/$DEVICE /master/master-submount
mount /dev/$DEVICE /slave/slave-submount
The --make-[r]private
flag stops further synchronisation. This is irreversible for any existing shares. Continuing the above example below, unmounting /master/master-submount
and /slave/slave-submount
will not now unmount the copies at /slave/master-submount
and /master/slave-submount
:
mount --make-rprivate /slave
umount /master/master-submount
umount /slave/slave-submount
The --make-[r]slave
flag can be used to break only updates to others, but still receive them. If rslave
had been used instead of rprivate
above, /master/slave-submount
would still not be unmounted by /slave
, but /slave/master-submount
would also have been unmounted by /master
.
The full documentation for these flags is not in the man
page, but is available at https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt.