6

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
akp
  • 1,753
  • 3
  • 18
  • 26

6 Answers6

8

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sankar Mani
  • 168
  • 3
4

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jeyaram
  • 9,158
  • 7
  • 41
  • 63
2

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

sigjuice
  • 28,661
  • 12
  • 68
  • 93
  • actually when i run my module system just hangs so i m not able do anything & i have to force reboot.i m trying with magic SysRq key sequences but i m not getting the result.. – akp Nov 02 '12 at 05:24
  • You may have to enable *magic sysrq* during your kernel's configuration and build. – Basile Starynkevitch Nov 02 '12 at 06:23
2

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

bdonlan
  • 224,562
  • 31
  • 268
  • 324
0

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.

john
  • 3
  • 2
0

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.

damian101
  • 91
  • 1
  • 2
  • 5