Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Linux kernel debug information after a kernel crash

Is there a way to get kernel previous debug information after kernel crash occurs.

I am trying to develop a kernel module which basically captures IP packets in the IP layer inside the kernel network stack and after some modification I have to send the same packet back to the NIC for transmission.

During all these processes I'm writing debug information with the help of printk(). But if any thing goes wrong and a kernel failure occurs, we have to restart the system. Is there a way to get my previous debug information, because after rebooting the debug information is not present as I try to get it by dmesg command?

like image 932
akp Avatar asked Nov 02 '12 05:11

akp


People also ask

What happens when a kernel crashes?

In a kernel panic, the kernel terminates abnormally. In a system crash, the kernel forcefully terminates a software execution after detecting an abnormal condition. The goal is to minimize data loss or corruption in the device.

Do you know panic and oops errors in kernel crash?

Oops is a way to debug kernel code, and there are utilities for helping with that. A kernel panic means the system cannot recover and must be restarted. However, with an Oops, the system can usually continue. You can configure klogd and syslogd to log oops messages to files, rather than to std out.


2 Answers

Actually, the /var/log/dmesg file contains the current boot print message log. The /var/log/kern.log file contains your previous boot kernel print message log in Ubuntu. In other Linux flavours it will contain in the /var/log/messages file in Fedora, etc..

like image 106
Sankar Mani Avatar answered Oct 31 '22 13:10

Sankar Mani


Kernel log messages can be viewed in /var/log/dmesg files even after restart of the system.

There will be so many files with dmesg.X, and those files are previous kernel logs. dmesg is the latest file.

See difference between dmesg and /var/log/kern.log

like image 30
Jeyaram Avatar answered Oct 31 '22 14:10

Jeyaram