Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I have an Ubuntu 10.04 install VM on a host. Latest 2.6.38-15-server kernel . /var/log/dmesg displays only the bootup but will stop recording after that. It will not show the trace/cpu_hung errors I am trying to troubleshoot. /var/log/dmesg.0 , dmesg.1 nothing - I did a string search for the text that displays on the console during the crash and NOTHING gets logged anywhere in /var/log/* .

I have to call into the provider and ask them to take a screenshot of the console since nothing shows in dmesg.

Why would /var/log/dmesg not record kernel panics, or such?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Whether you fix kernel logging past boot time or not will not help with kernel panic messages. When your kernel panics, it stops scheduling, so your logging daemon won't ever get to write down the kernel messages. If you want to grab those, you can look into kdump to get complete kernel core dumps and/or the netconsole kernel module to send the kernel messages over UDP to a remote syslog server.

As to getting kernel messages into /var/log/dmesg past boot time but outside of serious kernel crashes, try to have something like this in /etc/syslog.conf (or /etc/rsyslog.conf if using rsyslog):

kern.* /var/log/dmesg

For rsyslog, the file must also contain:

$ModLoad imklog.so

Let me know if you're using syslog-ng, it'd be a bit trickier to cover.

share|improve this answer
    
thanks for the info. –  Tom G Jul 6 '12 at 0:41
    
I have imklog.so in /etc/rsyslog.conf - perhaps you are correct - just thought everything was always logged - from console included - but if the system is halted i guess it couldn't write to it anyway –  Tom G Jul 6 '12 at 0:41
    
You also need kern.* /var/log/dmesg (and obviously not commented). –  Pierre Carrier Jul 6 '12 at 0:43

The reason is that /var/log/dmesg is a static file, created at the end of the boot process.

I'm more familiar with Debian, in which the /etc/init.d/bootmisc.sh file creates /var/log/dmesg in a call to savelog. Ubuntu does this through /etc/init/dmesg.conf.

For system logging during normal operations, you'll want to refer to /var/log/syslog, as Pierre Carrier notes.

Since a kernel panic frequently (though not always) breaks user processes (such as syslog) and disk I/O, you'll have to use a kernel logging feature (kdump, netconsole) to capture kernel panics. Another option is to log via serial console (possibly serial-over-LAN with appropriate IPMI/ILOM support), or with an attached gdb session.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.