mount_namespaces(7) Miscellaneous Information Manual mount_namespaces(7) mount_namespaces - namespaces(7). . . /proc/pid/mounts /proc/pid/mountinfo /proc/pid/mountstats ( proc(5)) pid. ( .) clone(2) unshare(2) CLONE_NEWNS. : o clone(2) . o unshare(2) . (mount(2) umount(2)) () ( ). . . 2.6.15. mount(2) umount(2) ( ). ( mount(2)) : MS_SHARED . mount(2) umount(2) . mount(2) umount(2) . mount(2) umount(2) . MS_PRIVATE . mount(2) umount(2) . MS_SLAVE mount(2) umount(2) (). mount(2) umount(2) . mount(2) umount(2) . ( .) MS_UNBINDABLE (bind mount). (mount(2) MS_BIND). (mount(2) MS_BIND MS_REC) ( ) . (NOTES). ( ) ( ). mount(2) umount(2) . . . : () () . . . . ( ). " " /proc/pid/mountinfo. ( proc(5) ). : shared:X X. . ( 1 ). master:X X. propagate_from:X ( 2.6.26) X. master:X. X . X master:X propagate_from:X. . unbindable . . MS_SHARED MS_PRIVATE /proc/self/mountinfo: sh1# mount --make-shared /mntS sh1# mount --make-private /mntP sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 77 61 8:17 / /mntS rw,relatime shared:1 83 61 8:15 / /mntP rw,relatime /proc/self/mountinfo /mntS 1 /mntP . . /mntS /mntP / : sh1# cat /proc/self/mountinfo | awk '$1 == 61' | sed 's/ - .*//' 61 0 8:2 / / rw,relatime : $ PS1='sh2# ' sudo unshare -m --propagation unchanged sh sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 222 145 8:17 / /mntS rw,relatime shared:1 225 145 8:15 / /mntP rw,relatime The new mount namespace received a copy of the initial mount namespace's mounts. These new mounts maintain the same propagation types, but have unique mount IDs. (The --propagation unchanged option prevents unshare(1) from marking all mounts as private when creating a new mount namespace, which it does by default.) /mntS /mntP : sh2# mkdir /mntS/a sh2# mount /dev/sdb6 /mntS/a sh2# mkdir /mntP/b sh2# mount /dev/sdb7 /mntP/b sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 222 145 8:17 / /mntS rw,relatime shared:1 225 145 8:15 / /mntP rw,relatime 178 222 8:22 / /mntS/a rw,relatime shared:2 230 225 8:23 / /mntP/b rw,relatime /mntS/a ( ) /mntP/b . /mntS ( ) /mntP : sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 77 61 8:17 / /mntS rw,relatime shared:1 83 61 8:15 / /mntP rw,relatime 179 77 8:22 / /mntS/a rw,relatime shared:2 MS_SLAVE mount(2) umount(2) . () ( ) mount(2) umount(2) . : sh1# mount --make-shared /mntX sh1# mount --make-shared /mntY sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 132 83 8:23 / /mntX rw,relatime shared:1 133 83 8:22 / /mntY rw,relatime shared:2 : sh2# unshare -m --propagation unchanged sh sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 168 167 8:23 / /mntX rw,relatime shared:1 169 167 8:22 / /mntY rw,relatime shared:2 : sh2# mount --make-slave /mntY sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 168 167 8:23 / /mntX rw,relatime shared:1 169 167 8:22 / /mntY rw,relatime master:2 /mntY 2. /mntX /mntY: sh2# mkdir /mntX/a sh2# mount /dev/sda3 /mntX/a sh2# mkdir /mntY/b sh2# mount /dev/sda5 /mntY/b /mntX/a ( "shared" ) /mntY/b : sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 168 167 8:23 / /mntX rw,relatime shared:1 169 167 8:22 / /mntY rw,relatime master:2 173 168 8:3 / /mntX/a rw,relatime shared:3 175 169 8:5 / /mntY/b rw,relatime ( ) /mntX/a ( /mntX) /mntY/b : sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 132 83 8:23 / /mntX rw,relatime shared:1 133 83 8:22 / /mntY rw,relatime shared:2 174 132 8:3 / /mntX/a rw,relatime shared:3 /mntY : sh1# mkdir /mntY/c sh1# mount /dev/sda1 /mntY/c sh1# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 132 83 8:23 / /mntX rw,relatime shared:1 133 83 8:22 / /mntY rw,relatime shared:2 174 132 8:3 / /mntX/a rw,relatime shared:3 178 133 8:1 / /mntY/c rw,relatime shared:4 ( 4): sh2# cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 168 167 8:23 / /mntX rw,relatime shared:1 169 167 8:22 / /mntY rw,relatime master:2 173 168 8:3 / /mntX/a rw,relatime shared:3 175 169 8:5 / /mntY/b rw,relatime 179 169 8:1 / /mntY/c rw,relatime master:4 MS_UNBINDABLE " " . . : # mount | awk '{print $1, $2, $3}' /dev/sda1 on / /dev/sdb6 on /mntX /dev/sdb7 on /mntY . : # mount --rbind / /home/cecilia/ # mount | awk '{print $1, $2, $3}' /dev/sda1 on / /dev/sdb6 on /mntX /dev/sdb7 on /mntY /dev/sda1 on /home/cecilia /dev/sdb6 on /home/cecilia/mntX /dev/sdb7 on /home/cecilia/mntY : # mount --rbind / /home/henry # mount | awk '{print $1, $2, $3}' /dev/sda1 on / /dev/sdb6 on /mntX /dev/sdb7 on /mntY /dev/sda1 on /home/cecilia /dev/sdb6 on /home/cecilia/mntX /dev/sdb7 on /home/cecilia/mntY /dev/sda1 on /home/henry /dev/sdb6 on /home/henry/mntX /dev/sdb7 on /home/henry/mntY /dev/sda1 on /home/henry/home/cecilia /dev/sdb6 on /home/henry/home/cecilia/mntX /dev/sdb7 on /home/henry/home/cecilia/mntY /home/henry /mntX /mntY /home/cecilia . : # mount --rbind / /home/otto # mount | awk '{print $1, $2, $3}' /dev/sda1 on / /dev/sdb6 on /mntX /dev/sdb7 on /mntY /dev/sda1 on /home/cecilia /dev/sdb6 on /home/cecilia/mntX /dev/sdb7 on /home/cecilia/mntY /dev/sda1 on /home/henry /dev/sdb6 on /home/henry/mntX /dev/sdb7 on /home/henry/mntY /dev/sda1 on /home/henry/home/cecilia /dev/sdb6 on /home/henry/home/cecilia/mntX /dev/sdb7 on /home/henry/home/cecilia/mntY /dev/sda1 on /home/otto /dev/sdb6 on /home/otto/mntX /dev/sdb7 on /home/otto/mntY /dev/sda1 on /home/otto/home/cecilia /dev/sdb6 on /home/otto/home/cecilia/mntX /dev/sdb7 on /home/otto/home/cecilia/mntY /dev/sda1 on /home/otto/home/henry /dev/sdb6 on /home/otto/home/henry/mntX /dev/sdb7 on /home/otto/home/henry/mntY /dev/sda1 on /home/otto/home/henry/home/cecilia /dev/sdb6 on /home/otto/home/henry/home/cecilia/mntX /dev/sdb7 on /home/otto/home/henry/home/cecilia/mntY . . : # mount --rbind --make-unbindable / /home/cecilia : # mkdir /mntZ # mount --bind /home/cecilia /mntZ mount: wrong fs type, bad option, bad superblock on /home/cecilia, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so. : # mount --rbind --make-unbindable / /home/henry # mount --rbind --make-unbindable / /home/otto : # mount | awk '{print $1, $2, $3}' /dev/sda1 on / /dev/sdb6 on /mntX /dev/sdb7 on /mntY /dev/sda1 on /home/cecilia /dev/sdb6 on /home/cecilia/mntX /dev/sdb7 on /home/cecilia/mntY /dev/sda1 on /home/henry /dev/sdb6 on /home/henry/mntX /dev/sdb7 on /home/henry/mntY /dev/sda1 on /home/otto /dev/sdb6 on /home/otto/mntX /dev/sdb7 on /home/otto/mntY The following table shows the effect that applying a new propagation type (i.e., mount --make-xxxx) has on the existing propagation type of a mount. The rows correspond to existing propagation types, and the columns are the new propagation settings. For reasons of space, "private" is abbreviated as "priv" and "unbindable" as "unbind". |make-shared make-slave make-priv make-unbind -------------+------------------------------------------------------- shared |shared slave/priv [1] priv unbind slave |slave+shared slave [2] priv unbind slave+shared |slave+shared slave priv unbind private |shared priv [2] priv unbind unbindable |shared unbind [2] priv unbind : [1] . [2] . (MS_BIND) : mount --bind A/a B/b A B a A b B. B/b A B . (A) |shared private slave unbind ------------------------------------------------+--------------------------------------------------------------------- (B) shared |shared shared slave+shared |shared private slave . ( ). Documentation/filesystems/sharedsubtree.rst . (MS_MOVE) : mount --move A B/b A B b B. B/b A B . (A) |shared private slave unbind ------------------------------------------------+--------------------------------------------------------------------- (B) shared |shared shared slave+shared |shared private slave unbindable : . Documentation/filesystems/sharedsubtree.rst . : mount device B/b B b B. B/b . : umount A A B/b B b B. B b B . propagate_from /proc/ pid /mountinfo propagate_from:X /proc/pid/mountinfo ( ) . - /mnt /tmp/etc /mnt/tmp/etc. chroot(1) /tmp/etc /mnt/tmp/etc () . /mnt /proc /mnt/proc proc(5) chroot chroot(1) . # mkdir -p /mnt/proc # mount --bind / /mnt # mount --bind /proc /mnt/proc /mnt ( ): # mount --make-private /mnt # # mount --make-shared /mnt # cat /proc/self/mountinfo | grep '/mnt' | sed 's/ - .*//' 239 61 8:2 / /mnt ... shared:102 248 239 0:4 / /mnt/proc ... shared:5 /mnt/etc /tmp/etc: # mkdir -p /tmp/etc # mount --bind /mnt/etc /tmp/etc # cat /proc/self/mountinfo | egrep '/mnt|/tmp/' | sed 's/ - .*//' 239 61 8:2 / /mnt ... shared:102 248 239 0:4 / /mnt/proc ... shared:5 267 40 8:2 /etc /tmp/etc ... shared:102 /tmp/etc /mnt/etc /tmp/etc : # mount --make-slave /tmp/etc # mount --make-shared /tmp/etc # cat /proc/self/mountinfo | egrep '/mnt|/tmp/' | sed 's/ - .*//' 239 61 8:2 / /mnt ... shared:102 248 239 0:4 / /mnt/proc ... shared:5 267 40 8:2 /etc /tmp/etc ... shared:105 master:102 /tmp/etc /mnt/tmp/etc. /mnt/tmp/etc /tmp/etc: # mkdir -p /mnt/tmp/etc # mount --bind /tmp/etc /mnt/tmp/etc # mount --make-slave /mnt/tmp/etc # cat /proc/self/mountinfo | egrep '/mnt|/tmp/' | sed 's/ - .*//' 239 61 8:2 / /mnt ... shared:102 248 239 0:4 / /mnt/proc ... shared:5 267 40 8:2 /etc /tmp/etc ... shared:105 master:102 273 239 8:2 /etc /mnt/tmp/etc ... master:105 /mnt /tmp/etc /mnt/tmp/etc. chroot(1) /mnt 267 (): # chroot /mnt chroot : # cat /proc/self/mountinfo | sed 's/ - .*//' 239 61 8:2 / / ... shared:102 248 239 0:4 / /proc ... shared:5 273 239 8:2 /etc /tmp/etc ... master:105 propagate_from:102 273 105. propagate_from ( ) 102 ( /mnt chroot(1)). . 2.4.19. . ( ) MS_SHARED MS_SHARED. MS_PRIVATE. MS_PRIVATE MS_SHARED . systemd(1) MS_SHARED . MS_SHARED. unshare(1) unshare(1) ( util-linux 2.27) systemd(1) . unshare(1) : mount --make-rprivate / To prevent this, one can use the --propagation unchanged option to unshare(1). clone(2) unshare(2) ( unshare(1)). MS_SLAVE MS_PRIVATE : mount(NULL, "/", MS_SLAVE | MS_REC, NULL); (MS_MOVE) (MS_BIND) Documentation/filesystems/sharedsubtree.rst. : [1] . . . [2] . . [3] . ( CLONE_NEWNS unshare(2) ). " " . : $ sudo sh # mount --bind /dev/null /etc/shadow # cat /etc/shadow # /etc/shadow. (umount(2)) /etc/shadow. . . . (umount(2)) : # unshare --user --map-root-user --mount \ strace -o /tmp/log \ umount /etc/shadow umount: /etc/shadow: not mounted. # grep '^umount' /tmp/log umount2("/etc/shadow", 0) = -1 EINVAL (Invalid argument) mount(8) strace(1) umount2(2) EINVAL . ( ) : # echo 'aaaaa' > /tmp/a # /etc/shadow # unshare --user --map-root-user --mount \ sh -c 'mount --bind /tmp/a /etc/shadow; cat /etc/shadow' aaaaa # umount /etc/shadow umount(8) /etc/shadow . [4] [3] (umount(2)) . unshare(1). . /mnt . $ PS1='ns1# ' sudo unshare --user --map-root-user \ --mount --propagation private bash ns1# echo $$ # PID 778501 ns1# mount --make-shared --bind /mnt /mnt ns1# mkdir /mnt/x ns1# mount --make-private -t tmpfs none /mnt/x ns1# mkdir /mnt/x/y ns1# mount --make-private -t tmpfs none /mnt/x/y ns1# grep /mnt /proc/self/mountinfo | sed 's/ - .*//' 986 83 8:5 /mnt /mnt rw,relatime shared:344 989 986 0:56 / /mnt/x rw,relatime 990 989 0:57 / /mnt/x/y rw,relatime ( ) /mnt. ns1# PS1='ns2# ' unshare --user --map-root-user \ --mount --propagation unchanged bash ns2# grep /mnt /proc/self/mountinfo | sed 's/ - .*//' 1239 1204 8:5 /mnt /mnt rw,relatime master:344 1240 1239 0:56 / /mnt/x rw,relatime 1241 1240 0:57 / /mnt/x/y rw,relatime /mnt [2]. /mnt "ns1" . nsenter(1) "ns1". /mnt/x /mnt/ppp. $ PS1='ns3# ' sudo nsenter -t 778501 --user --mount ns3# mount --rbind --make-private /mnt/x /mnt/ppp ns3# grep /mnt /proc/self/mountinfo | sed 's/ - .*//' 986 83 8:5 /mnt /mnt rw,relatime shared:344 989 986 0:56 / /mnt/x rw,relatime 990 989 0:57 / /mnt/x/y rw,relatime 1242 986 0:56 / /mnt/ppp rw,relatime 1243 1242 0:57 / /mnt/ppp/y rw,relatime shared:518 /mnt (recursive bind mount) /mnt "ns2" : ns2# grep /mnt /proc/self/mountinfo | sed 's/ - .*//' 1239 1204 8:5 /mnt /mnt rw,relatime master:344 1240 1239 0:56 / /mnt/x rw,relatime 1241 1240 0:57 / /mnt/x/y rw,relatime 1244 1239 0:56 / /mnt/ppp rw,relatime 1245 1244 0:57 / /mnt/ppp/y rw,relatime master:518 (umount(2)) (/mnt/ppp/y) "ns2" : ns2# umount /mnt/ppp/y umount: /mnt/ppp/y: not mounted. ns2# umount -l /mnt/ppp | sed 's/ - .*//' # ... ns2# grep /mnt /proc/self/mountinfo 1239 1204 8:5 /mnt /mnt rw,relatime master:344 1240 1239 0:56 / /mnt/x rw,relatime 1241 1240 0:57 / /mnt/x/y rw,relatime [5] mount(2) MS_RDONLY MS_NOSUID MS_NOEXEC "atime" ( MS_NOATIME MS_NODIRATIME MS_RELATIME) . . : $ sudo mkdir /mnt/dir $ sudo mount --bind -o ro /some/path /mnt/dir $ sudo unshare --user --map-root-user --mount \ mount -o remount,rw /mnt/dir mount: /mnt/dir: permission denied. [6] (rmdir(2)) ( ). . ( 3.18) EBUSY. ( NFS) ( ). pivot_root(2). unshare(1), clone(2), mount(2), mount_setattr(2), pivot_root(2), setns(2), umount(2), unshare(2), proc(5), namespaces(7), user_namespaces(7), findmnt(8), mount(8), pam_namespace(8), pivot_root(8), umount(8) Documentation/filesystems/sharedsubtree.rst . 3 . . : . 6.18 8 2026 mount_namespaces(7)