On Sunday 23 October 2011 16:21, Parmenides wrote: > Hi, > > I have built a initramfs. The /etc/inittab is: > > ::sysinit:/etc/init.d/rcS > tty1::askfirst:/bin/sh > tty2::askfirst:/bin/sh > tty3::askfirst:/bin/sh > tty4::askfirst:/bin/sh > tty5::askfirst:/bin/sh > tty6::askfirst:/bin/sh > ::restart:/sbin/init > ::ctrlaltdel:/sbin/reboot > ::shutdown:/bin/umount -a -r > > The /etc/init.d/rcS is: > > #!/bin/sh > mount -t proc proc /proc > mount -t sysfs sysfs /sys > mdev -s > mount /dev/hda1 /mnt > exec switch_root /mnt /sbin/init > > When the kernel booting, I got these message on the screen: > > BusyBox v1.19.2 (2011-10-22 16:15:41 CST) multi-call binary. > > Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS] > > Free initramfs and switch to another root fs: > chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /, > execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint. > > Options: > -c DEV Reopen stdio to DEV after switch > > I have check the conditions of switch_root as follows: > 1. 'ls /mnt' to ensure that the /dev/hda1 is mounted successfully. > 2. In rcS, the switch_root command is called by exec. So, the > switch_root command runs in the process with PID = 1.
No, switch_root's PID in your example is not 1. sysinit script is run as a *child* of init. If you plan to use switch_root, you don't want to use an init which uses inittab. Instead, arrange for a shell script to be run as init process, and make last command of this shellscript to be "exec switch_root ...". -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
