Custom initrd using busybox

Luciano Miguel Ferreira Rocha strange at nsk.no-ip.org
Sun Nov 5 17:20:31 UTC 2006


On Mon, Nov 06, 2006 at 01:09:43AM +0800, Moot Account wrote:
> Thanks! I'll try this when I get to the board (Soekris net4801) tomorrow.
> 
> But I have another question. How is /sbin/init ( ->busybox ) accessed.
> When I use:
> 
> exec /usr/sbin/chroot . /sbin/init <dev/console >dev/console 2>&1
> 
> the usage of init is printed. This probably means that init is not run
> as PID 1. Also, when I use /linuxrc it seems to be stuck.
> 
> Any ideas?

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.

You can change that behaviour by booting your kernel with "init=/linuxrc
root=/dev/ram0", and then the kernel runs linuxrc as init (IIRC).

Other option you could check out would be using initramfs instead of old
initrd:

1. name your script /init instead of /linuxrc;
2. call exec switch_root instead of pivot_root (and switch_root isn't
supposed to return, it calls init by itself);
3. create the new "initrd" as a new-format cpio file:
   find . -print0 | cpio -0oHnewc | gzip -9 > ../initrd.img

More information about initramfs and initrd can be found in a kernel
source tree:
- Documentation/initrd.txt
- Documentation/filesystems/ramfs-rootfs-initramfs.txt
- Documentation/early-userspace/README

-- 
lfr
0/0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20061105/32f2f1f3/attachment-0002.pgp 


More information about the busybox mailing list