Why '-c DEV' option for switch_root?

Harald Becker ralda at gmx.de
Thu Dec 5 10:10:39 UTC 2013


Hi !

On 05-12-2013 14:59 ChenQi <Qi.Chen at windriver.com> wrote:
>I noticed that switch_root in our busybox supports an extra
>option '-c DEV' which is not supported by the same command from
>util-linux. According to the source file, it's used to 'reopen
>stdio to DEV after switch'.
>
>Does anyone know why we need this option? Is there any use case
>where this option is useful or maybe necessary?

You probably need to reopen stdio after switching your root. As
long as you keep devices open, there are open file descriptors in
the kernel and the device i-nodes on the old file system can't
be deleted. Some programs do there own handling of devices and
reopen stdio in the new root, other may miss this reopen step
and you have to care of it for your own. In this case the -c
option simplify the switch usage, as it bundles the reopen in
same step as switching the root file system.  

--
Harald


More information about the busybox mailing list