[Gllug] Debugging kernel loading initrd

Nix nix at esperi.org.uk
Sun Apr 27 14:15:16 UTC 2008


On 27 Apr 2008, John Edwards uttered the following:

> On Sat, Apr 26, 2008 at 10:07:29PM +0100, Nix wrote:
>> works. If it doesn't, there's not a chance it'll work when the kernel
>> boots, either.
>
> Thanks again. Running in a chroot looks to be an easier way of
> debugging the initramfs than booting a kernel. The initramfs is
> actually a gzip'ed cpio archive, so instead of mounting it can be
> unpacked using:
>   gzcat <file> | cpio -idmu

Ah, you're keepig one initramfs and rebuilding it as needed? I found
myself getting into tangles with out-of-date modules when I did that, so
now I'm assembling it at build time via the kernel's build machinery
(that strange usr/ subdirectory of the kernel's source tree is not empty
for me).

> ------------------------------------------------------------
> $ sudo chroot ipcop-initrd/ /init
> Illegal instruction
> ------------------------------------------------------------
>
> This matches some other tests I ran where rdinit=/bin/hello-world
> would work, but rdinit=/bin/sh would fail.
>
> So the problem is almost certainly in busybox rather than anything
> to do with the kernel or the structure of the initramfs.

Suspect your uClibc as well and/or your toolchain. Built for i686,
maybe?

>> I doubt it. QEMU might be your best bet, but nothing aims for
>> bug-for-bug CPU emulation outside of ICEs internal to Intel, and perhaps
>> not even there.
>
> Thought so. Means I'm stuck with testing on a stack of ancient Pentiums.

This seems unlikely to be a CPU bug. Doesn't Bochs emulate a Pentium? 
Maybe you could use that...

>>> 2) Add debugging messages to the kernel code that loads the initrd.
>> 
>> The latter is the best bet. It's easy to get the kernel to spit out
>> debugging messages. ;}
>
> That's a joke right?

Nope, printk() is really quite easy to use.

My primary resource for tracking down non-driver-related kernel bugs is
to boot the thing in a UML and gdb it as needed. A shame the majority of
kernel bugs are driver bugs... :/

-- 
`If you are having a "ua luea luea le ua le" kind of day, I can only
 assume that you are doing no work due [to] incapacitating nausea caused 
 by numerous lazy demons.' --- Frossie
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list