Why '-c DEV' option for switch_root?
ChenQi
Qi.Chen at windriver.com
Mon Dec 9 02:09:51 UTC 2013
On 12/06/2013 06:28 PM, Laurent Bercot wrote:
>
>> I don't know if I understand it right.
>> Does it mean that as long as we don't do some strange redirections of
>> standard IO in our initramfs, we don't need to add this option when
>> switching root? So in most cases we don't need to reopen the stdio,
>> right?
>
> Unless your real root's /dev/console is the same file as your
> initramfs's /dev/console, you probably do.
>
> When your system boots, process 1 (and all its offspring, if there's
> no redirection) has fds 0, 1 and 2 pointing to your initramfs's
> /dev/console. That device will remain open as long as you don't close
> those fds. switch_root needs to reopen 0, 1 and 2 to your new
> /dev/console
> to be able to really clean up your initramfs.
>
Got it.
Thanks,
Chen Qi
> (The best solution is to stop using initramfs and boot directly on your
> real root filesystem, using a tmpfs to perform early operations that need
> writable space, and using pivot_root if you really need to change root
> filesystems. initramfs is a trap.)
>
More information about the busybox
mailing list