Custom initrd using busybox

Moot Account mootaccount at gmail.com
Sun Nov 5 17:09:43 UTC 2006


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?

Thanks again.

-Lenmarc

On 11/6/06, Luciano Miguel Ferreira Rocha <strange at nsk.no-ip.org> wrote:
> On Mon, Nov 06, 2006 at 12:30:01AM +0800, Moot Account wrote:
> > Hi,
> >
> > This is a bloated idea but it's just an exercise. The idea is to use
> > the rootfs from buildroot as the initrd (i.e. initrd=/boot/rootfs.gz).
> > This initrd should mount the _real_ rootfs using pivot_root. The real
> > rootfs is in the second partition (/dev/hda2) and is the _same_ rootfs
> > built from buildroot. In other words, rootfs.gz = rootfs in /dev/hda2.
> >
> > Inside the initrd (ie rootfs.gz) is /linuxrc which will be read first
> > by the kernel after mounting the initrd. Instead of pointing it to
> > /bin/busybox, I'm going to create a custom linuxrc.
> >
> > My _problem_ starts here. I CAN'T chroot to the rootfs in /dev/hda2
> > and execute the /linuxrc, which is still pointed /bin/busybox. I need
> > to chroot because /linuxrc will initialize my rootfs and put up the
> > login (ie /etc/inittab getty).
> >
> > Here are my arguments to the kernel:
> > linux /boot/bzImage console=ttyS0,9600
> > (since it's a serial console)
> >
> > This is the custom linuxrc that does _not_ work:
> >
> > #!/bin/sh
> > echo "linuxrc execute"
> > mount -t proc /proc /proc
> > mkdir new_root
> > mount -t ext2 /dev/hda2 /new_root
> > umount proc
> > cd /new_root
> > pivot_root . initrd
> > mount -t proc proc proc
> > mount -t devfs devfs dev
> > exec /usr/sbin/chroot . 'exec /linuxrc' \
> >         <dev/console >dev/console 2>&1
> >
> > I'm stuck after the execution pivot_root. It seems that dev/console is busy.
>
> And this stops linuxrc from continuing?
>
> Try:
>
> ...
> cd /new_root
> exec < dev/console &> dev/console
> pivot_root . initrd
> ...



More information about the busybox mailing list