Welcome to the Linux Foundation Forum!

How to Capture the Panic message?

Generate panic
Write a patch to panic the kernel. Capture panic message. generate and send the patch and dmesg output from the module to Shuah Khan skhan@linuxfoundation.org and also upload the file.

when I do sudo insmod panic.ko, kernel is getting panicked and stuck there. how to capture the panic message? Do I need to just make patch for panic.c and Makefile and send it? What do I put in the document in that case? can anybody explain it.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 10

    Use QEMU to capture the panic message:

    1. qemu-system-x86_64 \
    2. -kernel arch/x86_64/boot/bzImage \
    3. -nographic \
    4. -append "console=ttyS0" \
    5. -initrd /path/to/initramfs.img \
    6. -m 512 \
    7. --enable-kvm \
    8. -cpu host

    Typically, BusyBox is used in the initramfs, so insmod should be available to load your kernel module, but you have to include your kernel module in the initramfs image.

    Note: You don't necessarily need to panic the kernel from a kernel module. You can do the same in init/main.c, for example.

  • Posts: 1

    At the point of a kernel panic, the kernel itself is assumed to be in a bad state, such that it would be unsafe to write to the filesystem and risk corrupting it.

    The underlying kernel mechanism you might want to read about is Kdump. Kdump addresses the problem of how you can safely write to the filesystem by keeping a crash kernel loaded in main memory:
    https://wiki.archlinux.org/title/Kdump

    Most Linux distributions configure Kdump by default. You may find a core dump somewhere like /var/log/crash/, depending on your distribution. Arch and SteamOS are exceptions in that you will have to configure it yourself.

  • Posts: 18

    @gvernon said:
    At the point of a kernel panic, the kernel itself is assumed to be in a bad state, such that it would be unsafe to write to the filesystem and risk corrupting it.

    The underlying kernel mechanism you might want to read about is Kdump. Kdump addresses the problem of how you can safely write to the filesystem by keeping a crash kernel loaded in main memory:
    https://wiki.archlinux.org/title/Kdump

    Most Linux distributions configure Kdump by default. You may find a core dump somewhere like /var/log/crash/, depending on your distribution. Arch and SteamOS are exceptions in that you will have to configure it yourself.

    Thank you for this insight! Was able to successfully configure kdump and take a look at the logs post-crash.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training