From 3dcc463a036ca26f2ee3239a0e3bc88c00c3baf3 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Thu, 19 Jan 2017 09:31:56 +1300 Subject: [PATCH] mount_namespaces.7: Rework the discussion of defaults for mount propagation types Add rather more detail. In particular, note the cases where the default propagation type is MS_PRIVATE vs MS_SHARED. Reported-by: Rob Landley Signed-off-by: Michael Kerrisk --- man7/mount_namespaces.7 | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/man7/mount_namespaces.7 b/man7/mount_namespaces.7 index 087612965..cbc237585 100644 --- a/man7/mount_namespaces.7 +++ b/man7/mount_namespaces.7 @@ -165,8 +165,6 @@ peer mount points will propagate to this mount point. .BR MS_PRIVATE This mount point is private; it does not have a peer group. Mount and unmount events do not propagate into or out of this mount point. -This is the default propagation type for newly created mount points -(but see NOTES). .TP .BR MS_SLAVE Mount and unmount events propagate into this mount point from @@ -198,6 +196,9 @@ any bind mounts within the subtree are automatically pruned (i.e., not replicated) when replicating that subtree to produce the target subtree. .PP +For a discussion of the propagation type assigned to a new mount, +see NOTES. + The propagation type is a per-mount-point setting; some mount points may be marked as shared (with each shared mount point being a member of a distinct peer group), @@ -995,15 +996,29 @@ Mount namespaces first appeared in Linux 2.4.19. Namespaces are a Linux-specific feature. .\" .SH NOTES -The kernel default propagation type for mount points is +The propagation type assigned to a new mount point depends +on the propagation type of the parent directory. +If the mount point has a parent (i.e., it is a non-root mount +point) and the propagation type of the parent is +.BR MS_SHARED , +then the propagation type of the new mount is also +.BR MS_SHARED . +Otherwise, the propagation type of the new mount is .BR MS_PRIVATE . -However, +But see also NOTES. + +Notwithstanding the fact that the default propagation type +for new mount points is in many cases +.BR MS_PRIVATE , .BR MS_SHARED -is typically more commonly required, and for this reason, +is typically more useful. +For this reason, .BR systemd (1) automatically remounts all mount points as .BR MS_SHARED on system startup. +Thus, on most modern systems, the default propagation type is in practice +.BR MS_SHARED . Since, when one uses .BR unshare (1) @@ -1026,6 +1041,13 @@ To prevent this, one can use the .IR "\-\-propagation\ unchanged" option to .BR unshare (1). + +For a discussion of propagation types when moving mounts +.RB ( MS_MOVE ) +and creating bind mounts +.RB ( MS_BIND ), +see +.IR Documentation/filesystems/sharedsubtree.txt . .SH SEE ALSO .BR unshare (1), .BR clone (2),