|If you do not have a serial port and want to catch kernel output, check out netconsole.|
How to use the serial console in Linux
Find your serial ports.
dmesg | grep tty
Find out about them.
setserial -g /dev/ttyS
This may require getting setserial.
First, decide on serial parameters so you’re 100% consistent everywhere. 9600 Baud is a good speed for the ultimate compatibility, but it sometimes is too slow for fast refreshing console output. I use: 38400, 8, n, 1
If the BIOS supports serial redirect, that’s worth trying, but many BIOS implementations do a sketchy job (ahem Dell) so it’s best to at least turn that off after the bootloader and let Linux do it right.
Here’s a working grub.conf that does serial output.
default 0 timeout 7 serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console #splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Gentoo Linux 2.6.24-r5 root (hd0,0) kernel /boot/vmlinuz-2.6.33xed100305 root=/dev/md2 console=tty0 console=ttyS0,38400n8
Note that there are two timeouts, one for console and one for serial. Grub polls every second waiting for you to Press a Key to Continue thereby choosing where the output is sent. I guess you can have more time on one than the other, and I think it fails over to the other one after the first timeout. I’m not certain of that.
Next notice that there needs to be explicit serial settings in the grub configuration. The terminal command has both "serial" and "console" since generally you want the option to use either.
And finally you want the kernel to be passed an option to redirect to serial. There are two "console=" parameters which, like with GRUB, provide functionality to both output streams.
The kernel needs to have
SERIAL_CORE_CONSOLE CONFIG_SERIAL_8250_CONSOLE Device Drivers -> Character devices -> Serial drivers -> 8250/16550 and compatible serial support -> Console on 8250/16550 and compatible serial port
Then add the console parameters to your grub.conf file:
kernel /boot/vmlinuz root=/dev/md2 console=tty0 console=ttyS0,38400n8
Fancy console option parameters look like:
This actually just redirects the kernel messages on start up and shut down and other random times. That’s quite handy for troubleshooting of course which is usually why one would have serial out put at all. However to have actual interactive sessions you need to change the behavior of agetty.
You need to have inittab run agetty on a serial console. Do this by
/etc/inittab to include something like:
s0:12345:respawn:/sbin/agetty 38400 ttyS0 vt100
If you can log in through the normal keyboard and monitor as root, but
you can’t log in as root with the serial connection, you might need to
add the serial device to your list of permissible root login sources
which is found in
$ echo ttyS0 >> /etc/securetty
Use lsusb to find your USB to serial converter. Mine is a "Trendnet TU-S9" and works well in Linux. Here’s its lsusb profile: Bus 003 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port In your kernel configuration, you need to enable:
Device Drivers -> USB support -> USB Serial Converter support -> USB Prolific 2303 Single Port Serial Driver
Set up your minicom for 38400 8N1 with no flow control and enjoy.