Custom initrd using busybox
Rob Landley
rob at landley.net
Sun Nov 5 20:19:40 UTC 2006
On Sunday 05 November 2006 12:20 pm, Luciano Miguel Ferreira Rocha wrote:
> Ah, yes. You can't do that using linuxrc. Linuxrc isn't run as init (pid
> isn't 1). You're supposed to set the real root device writing to a /proc
> file (/proc/sys/kernel/real-root-dev), exit, and the kernel then mounts
> the real root device and executes init.
Using initramfs and switch_root is way more straightforward than this. And
doesn't have the magic behind the scenes stuff (like reparenting every
running process whose ".", "..", or "/" points to the old root, yes including
kernel threads).
Just sayin'...
Rob
> Other option you could check out would be using initramfs instead of old
> initrd:
>
> 1. name your script /init instead of /linuxrc;
Or supply the kernel the "rdinit=/blah" argument to tell it what you called
it.
> 2. call exec switch_root instead of pivot_root (and switch_root isn't
> supposed to return, it calls init by itself);
Don't forget the "exec". Common mistake. If it's not PID 1, it'll abort.
> 3. create the new "initrd" as a new-format cpio file:
> find . -print0 | cpio -0oHnewc | gzip -9 > ../initrd.img
The kernel can do this for you, if you prefer. And even build it into the
bzImage.
> - Documentation/filesystems/ramfs-rootfs-initramfs.txt
I wrote that one. If it's missing something, let me know.
I also wrote a couple articles for TimeSys, earlier this year. It's a little
long-winded, but might help:
http://www.timesys.com/timesource/march_06.htm
http://timesys.com/timesource/initramfs.htm
Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery
More information about the busybox
mailing list