How to debug the /sbin/init process?
Rob Landley
rob at landley.net
Sat Sep 10 03:13:15 UTC 2005
On Thursday 08 September 2005 21:03, Shawn Jin wrote:
> Hi,
>
> How can I use GDB to debug the first user space process /sbin/init
> when the kernel invokes this process?
User Mode Linux is fun for this sort of thing.
http://user-mode-linux.sourceforge.net/
My .config is:
cat >> .config << EOF &&
CONFIG_MODE_TT=y
CONFIG_LD_SCRIPT_STATIC=y
CONFIG_BINFMT_ELF=y
CONFIG_HOSTFS=y
CONFIG_SYSCTL=y
CONFIG_STDERR_CONSOLE=y
CONFIG_UNIX98_PTYS=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_INITRAMFS_SOURCE="initramfs/initramfs.txt"
CONFIG_LBD=y
CONFIG_EXT2_FS=y
CONFIG_PROC_FS=y
CONFIG_SQUASHFS=y
CONFIG_ZLIB_INFLATE=y
EOF
(You don't need the last two if you don't use squashfs). Then "make ARCH=um
oldconfig" and "make ARCH=um". Yeah, menuconfig works instead of
oldconfig. /dev/console will attach to stdio of the UML process (although
there's no controlling tty there so CTRL-C won't work; you need to patch the
linux kernel to get that. Use the xterms if you care that much.)
To invoke it, go:
./vmlinux rw rootfstype=hostfs mem=48M init=/bin/sh
You might want to give it a different amount of memory, might want to point
init at your init program instead of sh, and of course
"rootflags=/path/to/chroot/dir" is another fun command line option you might
want to look into to use something other than your host system's root
filesystem verbatim...
P.S. This is another entry in the "so you want to build a linux system out of
busybox" page. Not really quite on topic here, but not far off topic enough
to just ignore...
Rob
More information about the busybox
mailing list