[systemd-devel] remounting root fs outside containers as MS_SHARED

Djalal Harouni tixxdz at opendz.org
Thu May 15 06:42:30 PDT 2014


On Wed, May 14, 2014 at 10:17:59PM -0700, Ani Sinha wrote:
> >>
> >> Why pivot_root() fails ?
> >
> > pivot_root() fails because of the following code in linux kernel :
> >
> > http://lxr.free-electrons.com/source/fs/namespace.c#L2730
> >
> > any code that calls pivot_root() under / will fail with EINVAL.
> >
> 
> This is the redhat bug that discusses the kernel behavior :
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=847418
Lennart pointed to solution that handles bug 847418:
http://cgit.freedesktop.org/systemd/systemd/tree/src/core/switch-root.c

> So what is the position here? Do we have to live with a broken
> pivot_root() with this systemd change?

IMHO since this is chroot code, you should do after the unshare() mount
namespace:
mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)
mount(new_root, new_root, "bind", MS_BIND|MS_REC, NULL)
...

These two solutions should work for you!

-- 
Djalal Harouni
http://opendz.org


More information about the systemd-devel mailing list