Linux – How to see logs in a server after a kernel panic hang

kernel-paniclinuxlinux-kernel

I am running a production gentoo Linux machine, and recently there was a situation where the server hung in my co-located premises and when I got there I noticed that the server was hung on what appeared to be a kernel panic hang. I rebooted the machine with a hard reboot and was disappointed to find out that I could not find a shred of evidence anywhere on why the machine hung.

Is it true that when I do a hard reboot the messages itself will get lost or is there a setting I can do somewhere say in syslog-ng or maybe in sysctl to at least preserve the error log so that I can prevent such mishaps from happening in the future ? I am running a 2.6.x kernel by the way.

Thanks in advance.

Best Answer

To log a kernel panic, using netconsole is way easier than using a serial link ;)

There is a useful entry about it on ubuntu wiki that can be used on other linux flavors... Helped me for instance with archlinux.

Note that netconsole can be also be setup at boot.