akp
akp

Reputation: 1823

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?

Upvotes: 7

Views: 30462

Answers (6)

damian101
damian101

Reputation: 111

GNOME Logs is a very useful software for that. You can limit the log messages to the last session and easily read what the last messages before the crash were.

Upvotes: 0

Jeyaram
Jeyaram

Reputation: 9474

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

Upvotes: 5

Sankar Mani
Sankar Mani

Reputation: 178

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..

Upvotes: 9

john
john

Reputation: 33

Actually, the crash information (dmesg) is present in the location /var/crash/. Here we have the folders for every system crash. Folder names like 127.0.0.1-date-time. vmcore-dmesg.txt are present inside the folders. From these file, we have get the dmesg which are executed before the crash.

Upvotes: 3

bdonlan
bdonlan

Reputation: 231063

Recent versions of Linux support crash dumps. When successful, these will include a full dump of memory, including kernel log messages and stack traces.

Upvotes: 2

sigjuice
sigjuice

Reputation: 29749

You could try to interact with your hung system by entering magic SysRq key sequences via your keyboard or a serial console.

Upvotes: 2

Related Questions