How to capture all kernel panic on boot

Using Buildroot, I am trying to create my own kernel assembly. After creating the image and loading it in the VirtualBox environment, the kernel always panics after the GRUB stage. General summary of what I see:

] CPU: 0 PID: 1 ... ] Hardware name: innotek GmbH ... ] <some registers> ] Call Trace: ] [<c0a1c995>] dump_stack+... ] [<........>] panic+... ] [<........>] do_exit+... ] ... ] Kernel Offset: 0x0 from 0xc0400000 ... ] ---[ end Kernel panic - not syncing: Attempted to kill init! ... 

Now I assume that this is only the tail of the message that I want to see, but I do not have the means to view it (for example: Shift-PageUp cannot). When a panic occurs, the above text is never displayed for a second on the screen.

I first came across the KernelDebuggingTricks page which says:

Slow kernel messages at boot

... [Create] a kernel with the option enabled:

CONFIG_BOOT_PRINTK_DELAY = y

And boot the machine with the following kernel boot option:

boot_delay = N

I confirmed that my kernel (3.16) was built with the CONFIG_BOOT_PRINTK_DELAY option and tried to set boot_delay to 10, 500 and 1000 milliseconds in my GRUB. Even with a set delay of 1000 milliseconds (and waiting for a good ~ 5 minutes), all the messages from the panic trap logs break out in no time.

Does anyone have any suggestions on how I can consider the root of a kernel panic? The only thing I’m thinking about right now is to manually add sones to the kernel code (which I would like to avoid).

+5
source share
2 answers

Configure your virtual machine to enter the serial console, as well as the console, by adding console=ttyS0 console=tty0 to the boot options, and then configure the serial port of your computer (in the VirtualBox settings) for output to a file. If a kernel panic occurs, the details will be in this file.

See https://www.virtualbox.org/wiki/Serial_redirect for more details.

+5
source

kdump and netdump are two more options if you don’t have the convenience of a serial port, which is the case with metal for most modern laptops. See this answer for more information: https://unix.stackexchange.com/a/60928/32558 However, the installation is more active.

Finally, you may also be interested in debugging the kernel using JTAG or QEMU (not sure about Virtualbox support): Live Linux kernel debugging, how is this done and what tools are used?

0
source

Source: https://habr.com/ru/post/1200450/


All Articles