]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
unshare: add example for persistent mount namespace
authorKarel Zak <kzak@redhat.com>
Wed, 24 Feb 2016 12:28:19 +0000 (13:28 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Feb 2016 12:28:19 +0000 (13:28 +0100)
References: https://github.com/karelzak/util-linux/issues/289
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/unshare.1

index 71a0a3676c4ea3c57426c99bc559f9f78ff2e757..264f1396980994e394a44be5ca6d00aaf54a26e5 100644 (file)
@@ -62,7 +62,9 @@ by bind mount.
 .TP
 .BR \-m , " \-\-mount"[=\fIfile\fP]
 Unshare the mount namespace. If \fIfile\fP is specified then persistent namespace is created
-by bind mount.
+by bind mount. Note that \fIfile\fP has to be located on filesystem with
+propagation flag set to \fBprivate\fP. Use command \fBfindmnt -o+PROPAGATION\fP
+if not sure about the current setting. See also examples below.
 .TP
 .BR \-n , " \-\-net"[=\fIfile\fP]
 Unshare the network namespace. If \fIfile\fP is specified then persistent namespace is created
@@ -153,6 +155,21 @@ FOO
 .br
 Establish a persistent UTS namespace, modify hostname. The namespace maybe later entered
 by nsenter. The namespace is destroyed by umount the bind reference.
+
+.TP
+.TQ
+.B # mount --bind /root/namespaces /root/namespaces
+.TQ
+.B # mount --make-private /root/namespaces
+.TQ
+.B # touch /root/namespaces/mnt
+.TQ
+.B # unshare --mount=/root/namespaces/mnt
+.br
+Establish a persistent mount namespace referenced by the bind mount
+/root/namespaces/mnt. This example provides portable solution, because it makes
+sure that the bind mount is created on shared filesystem.
+
 .SH SEE ALSO
 .BR unshare (2),
 .BR clone (2),