Busybox Init

Rajeev Bansal rajeevb at intoto.com
Wed Dec 5 06:19:21 PST 2007


Hi All,

I could find the problem in my init script, actually I was using 
switchroot command to move from my old root to new root. But busybox 
gives switch_root in place of switchroot. So when I replaced the 
switchroot with switch_root command, I could see it was mounting the new 
root fs that is /dev/sda2 in my case. But after that it was giving me 
the Kernel panic. I don't know why it was behaving like that. Ideally 
kernel should go and execute /sbin/init. I am mentioning below my new 
init script.
#!/bin/nash

mount -t proc /proc /proc
setquiet
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
mount -o mode=0755 -t tmpfs /dev /dev
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
mkdir /dev/shm
mkdir /dev/mapper
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/rtc c 10 135
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
echo Creating block device nodes.
mkblkdevs
echo "Loading usbcore.ko module"
insmod /lib/usbcore.ko
echo "Loading uhci-hcd.ko module"
insmod /lib/uhci-hcd.ko
echo "Loading ohci-hcd.ko module"
insmod /lib/ohci-hcd.ko
echo "Loading ehci-hcd.ko module"
insmod /lib/ehci-hcd.ko
mount -t usbfs /proc/bus/usb /proc/bus/usb
echo "Loading mbcache.ko module"
insmod /lib/mbcache.ko
echo "Loading jbd.ko module"
insmod /lib/jbd.ko
echo "Loading ext3.ko module"
insmod /lib/ext3.ko
echo "Loading scsi_mod.ko module"
insmod /lib/scsi_mod.ko
echo "Loading sd_mod.ko module"
insmod /lib/sd_mod.ko
echo "Loading sg.ko module"
insmod /lib/sg.ko
echo "Loading libata.ko module"
insmod /lib/libata.ko
echo "Loading ata_generic.ko module"
insmod /lib/ata_generic.ko
echo "Loading ata_piix.ko module"
insmod /lib/ata_piix.ko
echo Waiting for driver initialization.
stabilized --hash --interval 250 /proc/scsi/scsi
insmod /lib/scsi_wait_scan.ko
rmmod scsi_wait_scan
mkblkdevs
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro sda2
echo Mounting root filesystem.
mount /sysroot
echo Switching to new root and running init.
switch_root /dev/sda2 /sbin/init   ------------------------> I tried 
switch_root with or without arguments also.
ls -l
echo Booting has failed.
sleep -1

Thanks
Rajeev Bansal.

Loïc Grenié wrote:
> 2007/12/5, Rajeev Bansal <rajeevb at intoto.com>:
>   
>> Hello Walter,
>>
>> Please see below mentioned text which I extracted from
>> "ramfs-rootfs-initramfs.txt"
>>
>> What is initramfs?
>>     
>
> [snip]
>
>   
>> So according to them , it's init responsibility to mount the real root
>> device, I think VI init works in that way, but not sure about the
>> busybox Init. Can anyone clarify me that?
>>     
>
>     In the initramfs system you have no real init, in the usual UNIX sense.
>   There is a program that does some initialization of the software, often
>   loads module and mount real root file system, and launch /sbin/init
>   of the real root filesystem. This are two conceptually different things,
>   which unfortunately share the same name. The "init" that is present
>   in BB is not the one to put on an initramfs. You should really try another
>   mailing-list, because this one is not the correct one.
>
>          Loïc Grenié
>
>
>   



********************************************************************************
This email message (including any attachments) is for the sole use of the intended recipient(s) 
and may contain confidential, proprietary and privileged information. Any unauthorized review, 
use, disclosure or distribution is prohibited. If you are not the intended recipient, 
please immediately notify the sender by reply email and destroy all copies of the original message. 
Thank you.
 
Intoto Inc. 



More information about the busybox mailing list