Custom initrd using busybox
Luciano Miguel Ferreira Rocha
strange at nsk.no-ip.org
Sun Nov 5 16:52:52 UTC 2006
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
...
--
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/78ae3c9d/attachment-0002.pgp
More information about the busybox
mailing list