There are several ways to capture kernel log output on a remote machine. One way is to configure the kernel to use a serial port as console. If you have a machine that has a serial port, or you’re running a VM, this method can be very helpful in capturing kernel log data when a panic occurs.

On Debian (or Ubuntu) this is really easy to setup. Simply edit /etc/default/grub and change the line:



GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8 debug ignore_loglevel"

and then execute:

$ update-grub

and reboot. Let’s examine this a bit closer:

console=tty0 instructs the kernel to continue using the standard console device so you’ll still see the usual boot messages on an attached monitor.

console=ttyS0, instructs the kernel to also use the first serial device as a console. If you have multiple serial ports, you can change the number to match the device you wish to use.

115200n8 sets the serial speed to 115200 bits per second with no parity and 8 data bits per character. The other end of the serial line must be configured to match these settings.

debug ignore_loglevel allows you to see ALL kernel messages on the configured console(s). If you’re trying to debug your kernel, you will most certainly want this.

If your machine is running in a VM, the management utility likely has a configuration that will allow you to write the console data to a file on the host machine. If you intend to use a real serial port and cable, you can use any serial communication program. I use minicom, the command I use is:

minicom -D /dev/ttyUSB0 -b 115200n8 -m -o -w

I use a serial-to-usb converter as my laptop does not have a proper serial port. This device communicates on /dev/ttyUSB0. See the manpage for minicom for additional options.