Getting linux kernel debug information after kerne

2020-03-22 06:35发布

问题:

Is there any way to get kernel previous debug information after kernel chrash occurs.

I am trying to develop a Kernel module which basically captures IP packets in ip layer inside kernel network stack & 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 & kernel failure occurs so we have to restart the system . So is there any way to get my previous debug info because after rebooting the debug info is not present as i try to get it by dmesg command.

回答1:

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



回答2:

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, those files are previous kernel logs. dmesg is the latest file.

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



回答3:

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



回答4:

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



回答5:

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.