2005-05-16 10:08:28

by Lai Zit Seng

[permalink] [raw]
Subject: pivot_root()

Not sure where to post this, forgive me if there is a better place to
post...

I'm trying to use pivot_root() to change root to a directory that is not
a mount point, i.e. it is under a mount point of a different device from
the current root device.

E.g.

# /root is mounted from /dev/sda1
pivot_root("/root/somewhere", "/root/somewhere/initrd");

But pivot_root() returns EINVAL. Both /root/somewhere and
/root/somewhere/initrd exists.

Any pointers about what might be wrong? Many thanks :)

Regards,

.lzs


2005-05-16 13:58:03

by Serge E. Hallyn

[permalink] [raw]
Subject: Re: pivot_root()

Quoting Lai Zit Seng ([email protected]):
> Not sure where to post this, forgive me if there is a better place to
> post...
>
> I'm trying to use pivot_root() to change root to a directory that is not
> a mount point, i.e. it is under a mount point of a different device from
> the current root device.
>
> E.g.
>
> # /root is mounted from /dev/sda1
> pivot_root("/root/somewhere", "/root/somewhere/initrd");
>
> But pivot_root() returns EINVAL. Both /root/somewhere and
> /root/somewhere/initrd exists.
>
> Any pointers about what might be wrong? Many thanks :)

Try first doing

mount --bind <newroot> <newroot>

See the comments above fs/namespace.c:sys_pivot_root() for the
explanation.

-serge

2005-05-16 15:26:38

by Lai Zit Seng

[permalink] [raw]
Subject: Re: pivot_root()

Yes you're right. Thanks!

Regards,

.lzs
http://thinkingfarm.com/~lzs/

On Mon, 16 May 2005 [email protected] wrote:
> Try first doing
>
> mount --bind <newroot> <newroot>
>
> See the comments above fs/namespace.c:sys_pivot_root() for the
> explanation.
>
> -serge