Having problems with init

Denys Vlasenko vda.linux at googlemail.com
Tue Nov 2 18:17:06 UTC 2010


On Tuesday 02 November 2010 17:44, Dallas Clement wrote:
> I'm struggling to get init to find /etc/init.d/inittab and or execute
> /etc/init.d/rcS.  It just sits and waits on nanosleep.  I have
> included the strace output below.
> 
> I'm using version 1.7.0 ( I know it's a bit old, but I'm not able to
> upgrade it for this project ).
> 
> I don't think I'm doing anything too out of the ordinary.  I am able
> to successfully NFS mount my root file system.  I execute the
> following from my initrd / linuxrc:
> 
> 	/sbin/ifconfig eth1 192.168.1.40 up
> 	mount -o nolock 192.168.1.5:/home/dallasc/development/cs/BTUS/hddroot/img /mnt
> 	cd /mnt
> 	mkdir -p initrd
> 	ls .
> 	/sbin/pivot_root . initrd
> 	if [ $? != 0 ]; then
> 		echo "pivot root failed"
> 	else
> 		exec chroot . /usr/local/bin/strace /sbin/init \
> <dev/console >dev/console 2>&1
> 		umount /initrd
> 
> If I replace /sbin/init with /bin/sh, I get a shell prompt and I can
> look at my NFS mounted root fs.  So I know that the exec is working
> and I can execute binaries over NFS.
> 
> init however just sits and waits forever on nanosleep.  I don't see it
> attempt to open the inittab file or the rcS file.  Could it perhaps be
> a UID or PID problem?

Yes:

        if (!DEBUG_INIT) {
                /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */
                if (getpid() != 1
                 && (!ENABLE_FEATURE_INITRD || !strstr(applet_name, "linuxrc"))
                ) {
                        bb_show_usage();
                }
#ifdef RB_DISABLE_CAD
                /* Turn off rebooting via CTL-ALT-DEL - we get a
                 * SIGINT on CAD so we can shut things down gracefully... */
                reboot(RB_DISABLE_CAD); /* misnomer */
#endif
        }

See? It checks PID == 1. And under strace, PID will not be 1.
(Unless you run strace -D, which requires very recent strace).

Why you don't see bb_show_usage() output I don't know -
perhaps you compiled without CONFIG_SHOW_USAGE?

That init sleeps after this instead of exiting is a known bug,
it will be fixed in 1.18.x

What happens if you don't run init under strace, or if you run
it under strace -D?

-- 
vda


More information about the busybox mailing list