Re: How do I make a clean mount namespace?

From: Richard Weinberger
Date: Wed Apr 23 2014 - 16:01:37 EST


On Wed, Apr 23, 2014 at 12:12 AM, Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
> I want to set up a little container. So I unshare the mount namespace
> and mount something somewhere (say /mnt) that I want to be my new
> root. Now what?
>
> pivot_root("/mnt", "/mnt/garbage") seems to frequently return -EBUSY.
>
> mounting /mnt onto / using MS_MOVE seems to succeed, but / still
> points at the old root.
>
> Am I missing a clean way to do this? I want a way to say "make this
> mountpoint be the root of the whole mount namespace and lazy-unmount
> everything outside it". If there is no straightforward way to do
> that, can we add one?

I fear you have to read /proc/mounts and umount() everything in the
correct order.
If you find a better way, please tell. :-)

--
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/