Martin Hicks
2003-Nov-28 13:01 UTC
[klibc] problems when exec()ing /sbin/init from an initramfs
This is an early userspace type question. I have an initramfs that does some root device setup, then tries to mount the real root partition and exec /sbin/init to start the real userland. It seems to do what I want, except that bootlogd hangs while mount /proc. I can't seem to figure out why. I'm booting with init=/bin/bash. bash is dynamically linked, and the appropriate libs are in /lib on the initramfs. This may be a stupid idea, but it's only for initial testing. Kernel 2.6.0-test10 on ia64. Distro is debian unstable. I edited the /etc/init.d/bootlogd script so it would execute as "/bin/sh -x", and I straced the daemon when it started. Here is a transcript. Any ideas? I just can't fathom why proc would hang during the mount call. bash-2.05b# mount -t proc none /proc bash-2.05b# mkdir /sys bash-2.05b# mount -t sysfs none /sys bash-2.05b# /sbin/insmod mptbase.ko [random messages...] bash-2.05b# /sbin/insmod mptscsih.ko bash-2.05b# /sbin/insmod sd_mod.ko [boatloads of messages from /sbin/hotplug & udev] bash-2.05b# mount /udev/xscsi/pci20.01.1-1/target2/lun0/part2 /newroot/ bash-2.05b# umount /sys bash-2.05b# umount /proc bash-2.05b# rm -rf /newroot/udev/* bash-2.05b# cp -a /udev/* /newroot/udev/ bash-2.05b# cd newroot/ bash-2.05b# pivot_root . oldroot bash-2.05b# exec /usr/sbin/chroot . /sbin/init <dev/console >dev/console 2>&1 INIT: version 2.85 booting + PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + DAEMON=/sbin/bootlogd + NAME=bootlogd + DESC=Bootlog daemon + PIDFILE=/var/run/bootlogd.pid + test -f /sbin/bootlogd + . /etc/default/rcS ++ TMPTIME=0 ++ SULOGIN=no ++ DELAYLOGIN=yes ++ UTC=no ++ VERBOSE=yes ++ EDITMOTD=yes ++ FSCKFIX=no + '[' '' ']' + '[' start = stop ']' + echo -n 'Starting Bootlog daemon: ' Starting Bootlog daemon: + '[' -d /proc/1/. ']' + /usr/bin/strace /sbin/bootlogd -r execve("/sbin/bootlogd", ["/sbin/bootlogd", "-r"], [/* 13 vars */]) = 0 uname({sys="Linux", node="(none)", ...}) = 0 brk(0) = 0x6000000000010000 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x200000000002c000 open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=14019, ...}) = 0 mmap(NULL, 14019, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2000000000030000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/tls/libutil.so.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\240\32"..., 640) = 640 fstat(3, {st_mode=S_IFREG|0644, st_size=15704, ...}) = 0 mmap(NULL, 78984, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2000000000040000 mprotect(0x2000000000044000, 62600, PROT_NONE) = 0 mmap(0x2000000000050000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x2000000000050000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/tls/libc.so.6.1", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\0\311"..., 640) = 640 fstat(3, {st_mode=S_IFREG|0644, st_size=2304280, ...}) = 0 mmap(NULL, 2378936, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2000000000054000 mmap(0x2000000000284000, 81920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x220000) = 0x2000000000284000 mmap(0x2000000000298000, 3256, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x200000000020close(3) = 0 mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x200000000029c000 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x20000000002a4000 munmap(0x2000000000030000, 14019) = 0 rt_sigaction(SIGTERM, {0x4000000000003ef0, [], SA_RESTART}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGQUIT, {0x4000000000003ef0, [], SA_RESTART}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGINT, {0x4000000000003ef0, [], SA_RESTART}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGTTIN, {SIG_IGN}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGTTOU, {SIG_IGN}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGTSTP, {SIG_IGN}, {SIG_DFL}, 8) = 0 fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(5, 1), ...}) = 0 stat("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat("/proc", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 mount("proc", "/proc", "proc", , 0 TIA, mh -- Martin Hicks Wild Open Source Inc. mort@wildopensource.com 613-266-2296
Martin Hicks
2003-Nov-30 12:13 UTC
[klibc] problems when exec()ing /sbin/init from an initramfs
On Fri, 2003-11-28 at 16:01, Martin Hicks wrote:> This is an early userspace type question. I have an initramfs that does > some root device setup, then tries to mount the real root partition and > exec /sbin/init to start the real userland. It seems to do what I want, > except that bootlogd hangs while mount /proc. I can't seem to figure > out why.Seems to be a kernel problem. It works fine if I use an old-style initrd. There must be some problem with switching from ramfs / to a real / then trying to mount /proc again. Investigating will continue... mh -- Martin Hicks || mort@bork.org || PGP/GnuPG: 0x4C7F2BEE -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://www.zytor.com/pipermail/klibc/attachments/20031130/e12359e2/attachment.bin