From 249fc8fe899f51fad1eda05e97b38633ea78119f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 24 Feb 2016 13:28:19 +0100 Subject: unshare: add example for persistent mount namespace References: https://github.com/karelzak/util-linux/issues/289 Signed-off-by: Karel Zak --- sys-utils/unshare.1 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sys-utils/unshare.1') diff --git a/sys-utils/unshare.1 b/sys-utils/unshare.1 index 71a0a3676..264f13969 100644 --- a/sys-utils/unshare.1 +++ b/sys-utils/unshare.1 @@ -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), -- cgit v1.2.3-55-g7522