switch_root and centos

Denys Vlasenko vda.linux at googlemail.com
Tue Dec 15 00:55:13 UTC 2009


On Monday 14 December 2009 20:53, Christopher Barry wrote:
> On Sun, 2009-12-13 at 22:30 -0500, Michael Di Domenico wrote:
> > Can anyone point me towards a how-to that shows step by step how to
> > boot up busybox and then switch_root to Centos installed on a local
> > hard drive and start that up?
> > 
> > After messing with busybox for a few days, i've gotten it to pxe boot
> > and run inside QEMU, but i'm having the hardest time getting
> > switch_root to startup Centos fully
> > 
> > The first problem i hit is the infamous "not rootfs", which i can see
> > is controlled by conditions, though have no idea which one i'm failing
> > on (a more verbose error msg would have been nice).  I commented out
> > the conditions and it does seem to pivot root, but doing
> > 
> > exec switch_root /newroot /etc/rc.d/rc.sysinit
> > 
> > looks like things are going to startup and it pushes through some of
> > the sysinit scripts, but then dumps me back into busybox
> > 
> > Which led me to believe its not really invoking /sbin/init, but when i do
> > 
> > exec switch_root /newroot /sbin/init 3
> > 
> > I get 'timeout opening/waiting for initctl'

This message suggests /sbin/init thinks it isn't the init, but telinit.
It may think so if PID != 1. Can you add "echo mypid:$$" before exec?
What does it say?

> > #!/bin/sh
> > 
> > mount -t proc proc /proc
> > mount -t sysfs sysfs /sys
> > mount -t tmpfs tmpfs /dev
> > 
> > echo "Creating initial device nodes"
> > mdev -s

Why do you do it? You probably need /dev/null,
nothing more. mknod it, or pre-create.

> > echo "Loading jbd.ko module"
> > insmod /lib/modules/jbd.ko
> > echo "Loading ext3.ko module"
> > insmod /lib/modules/ext3.ko
> > echo "Loading scsi_mod.ko module"
> > insmod /lib/modules/scsi_mod.ko
> > echo "Loading sd_mod.ko module"
> > insmod /lib/modules/sd_mod.ko
> > echo "Loading libata.ko module"
> > insmod /lib/modules/libata.ko
> > echo "Loading pata_sis.ko module"
> > insmod /lib/modules/pata_sis.ko
> > echo "Loading sata_sis.ko module"
> > insmod /lib/modules/sata_sis.ko
> > echo "Loading ata_piix.ko module"
> > insmod /lib/modules/ata_piix.ko
> > echo "Loading mii.ko module"
> > insmod /lib/modules/mii.ko
> > echo "Loading e1000.ko module"
> > insmod /lib/modules/e1000.ko
> > echo "Loading sis900.ko module"
> > insmod /lib/modules/sis900.ko
> > 
> > mount /dev/hda /newroot
> > exec switch_root /newroot /sbin/init 3

Oops... you forgot to unmount /dev, /proc and /sys.
--
vda


More information about the busybox mailing list