On 12/08/13 20:09, ChenQi wrote:
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.
It's actually probably obsolete these days, now that we have initmpfs
and can mount --move the initrmpfs into the new root filesystem. My code
did it because the klibc code was doing it, but I vaguely recall the
initial reason was not relying on a node that would no longer be
accessible and thus provide confusing information in /proc/1/fd, or some
such. (Really, you'd have to ask the klibc guys why.)
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.)
That's actively bad advice.
The most recent kernel has my initmpfs patches, meaning initramfs can
now be a tmpfs instead of ramfs.
This means it has size limits (50% by default, changeable with -o
remount, so "cat /dev/zero > /blah" won't fill up memory and freeze the
box). It means it reports available space so trying to use something
like "rpm" that checks available space before proceeding should work out
of one of those. And it means that it should show up in a sanely written
df (which filters out 0 block filesystems so it doesn't show /proc and
/sys and stuff). Plus the usual "memory in this can swap to swap
partitions if you've got 'em" that tmpfs provides.
Of course some people special case initramfs in their code because they
don't understand how the system works, and thus when you use initramfs
as your rootfs their code doesn't see it even when it's not overmounted.
But that's because those people wrote broken code.
Rob
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox