Having problems with init
Dallas Clement
dallas.a.clement at gmail.com
Tue Nov 2 18:17:08 UTC 2010
Hello again,
I found the answer to my own problem. It turns out that 'init' was
not reading inittab or running rcS because my PID != 1. So in other
words, init needs to be run as the special init process ID 1. I
actually already knew that, but never suspected that my PID would not
be 1 since I was doing my pivot_root from my initrd / linuxrc script.
It turns out that two options *must* be explicitly added to the linux
command line for your PID to be 1.
You should add root=/dev/ram0 and init=/linuxrc if you want your PID
to be 1 and busybox init to work.
It would sure be nice if busybox init produced some sort of error
message if PID != 1. It could save a lot of grief. Finding this
information is challenging to say the least!!
Dallas
On Tue, Nov 2, 2010 at 11:44 AM, Dallas Clement
<dallas.a.clement at gmail.com> wrote:
> Hi All,
>
> 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?
>
> Any help, much appreciated.
>
> Thanks,
>
> Dallas
>
> execve("/sbin/init", ["/sbin/init"], [/* 8 vars */]) = 0
> brk(0) = 0xde000
> uname({sys="Linux", node="(none)", ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0x4001d000
> access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
> open("/etc/ld.so.cache", O_RDONLY) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=7909, ...}) = 0
> mmap2(NULL, 7909, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4001e000
> close(3) = 0
> open("/lib/libm.so.6", O_RDONLY) = 3
> read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0342\0\000"...,
> 512) = 512
> fstat64(3, {st_mode=S_IFREG|0755, st_size=739248, ...}) = 0
> mmap2(NULL, 712856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
> 0) = 0x40026000
> mprotect(0x400cc000, 28672, PROT_NONE) = 0
> mmap2(0x400d3000, 8192, PROT_READ|PROT_WRITE,
> MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa5) = 0x400d3000
> close(3) = 0
> open("/lib/libc.so.6", O_RDONLY) = 3
> read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\340J\1\000"...,
> 512) = 512
> fstat64(3, {st_mode=S_IFREG|0755, st_size=1481034, ...}) = 0
> mmap2(NULL, 1237404, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
> 3, 0) = 0x400d5000
> mprotect(0x401f7000, 28672, PROT_NONE) = 0
> mmap2(0x401fe000, 12288, PROT_READ|PROT_WRITE,
> MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x121) = 0x401fe000
> mmap2(0x40201000, 8604, PROT_READ|PROT_WRITE,
> MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40201000
> close(3) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0x40020000
> syscall_983045(0x400204a0, 0x400256f4, 0x40020b78, 0x40025058, 0x40,
> 0x40025000, 0, 0xf0005, 0x40025738, 0x1, 0, 0xbe87cbbc, 0, 0xbe87c930,
> 0x88, 0x40002290, 0x20000010, 0x400204a0, 0, 0, 0xdbe0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0) = 0
> mprotect(0x401fe000, 8192, PROT_READ) = 0
> mprotect(0x400d3000, 4096, PROT_READ) = 0
> munmap(0x4001e000, 7909) = 0
> getpid() = 629
> getuid32() = 0
> brk(0) = 0xde000
> brk(0x109000) = 0x109000
> mmap2(NULL, 401408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x40204000
> munmap(0x40204000, 401408) = 0
> write(2, "BusyBox v1.15.3 (2010-04-23 20:1"..., 41BusyBox v1.15.3
> (2010-04-23 20:10:06 JST)) = 41
> write(2, " multi-call binary\n", 19 multi-call binary
> ) = 19
> write(2, "\nUsage: ", 8
> Usage: ) = 8
> write(2, "init", 4init) = 4
> write(2, " ", 1 ) = 1
> write(2, "\n\nInit is the parent of all proc"..., 37
>
> Init is the parent of all processes) = 37
> write(2, "\n\n", 2
>
> ) = 2
> rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
> rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
> rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> nanosleep({2592000, 0},
>
More information about the busybox
mailing list