Serial Console Goodness

If you’re tired of messing around with KVM switches, monitors and keyboards, or need remote console access to your server, a serial console may be just what you need! It’s far easier than you think, and it’s convienent, especialy if you have a laptop or a really long serial cable to your desktop. Please note that the configs discussed here are for pure serial console access under Linux; if you need to mix the keyboard and mouse with serial console or you aren’t using Linux you can find that info with Google.

Some (most?) real server hardware has an option to redirect BIOS to a serial console. The Dell servers I’ve used do this and it allows you to interact with the system before it hits the bootloader. Enable it, it’s handy. Next you’ll probably want to redirect your bootloader to a serial console. If you’re using GRUB, simply add the following lines to your grub config file:

serial --unit=0 --speed=115200
terminal serial

Note: the unit number can be 0 through 3, which corresponds to COM1 through COM4. Speed can be any valid RS-232 speed from 300 to 115200. I use 115200 on all my serial consoles, but if you aren’t sure what equipment may need to connect to it, 9600 is always a safe bet. GRUB assumes vt100 unless you specify –dumb since most all terminal equipment supports vt100. Or if you’re using LILO:

serial = 0,115200n8

Tell the Linux kernel to send all of its console messages to the serial port. Append the following to your kernel boot line:

console=ttyS0,115200

Replace ttyS0 with the proper serial port if you aren’t using COM1. COM2 would be ttyS1 and so forth; the speed setting can be changed as well. Note that if you boot into single user mode the console will be the serial port. Finally, you should spawn a getty on the serial port after the system boots. Add (or uncomment, most distros have this at the bottom already) to your /etc/inittab file:

T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100

(Some versions of getty, such as the one included with Red Hat 7.3, may require you to drop the -L flag. Try it both ways until it works.)

After saving the inittab file run telinit q to reread it. The serial console should become active immediately. Again, the port and speed settings can be changed to suit your needs.

That’s it! Reboot your server with your favorite terminal program (TeraTerm, Zterm, HyperTerminal, tip, minicom, etc.) connected to the serial port and see if it all works. When using your serial console don’t be tempted to enlarge the terminal window past 80×24 (80 cols 24 lines) since a lot of things will get confused and redraw the terminal quite badly. Yes, it’s small, but that’s why you have a scrollback buffer. With a serial console you’ll never need to use a keyboard and monitor on your server unless it dies in the POST phase, at which point you’ve got bigger problems than making room for a monitor.

Now for a quick recap (or for the impaitent):

For GRUB:
serial --unit=0 --speed=115200
terminal serial

For LILO:
serial = 0,115200n8

Kernel boot line:
console=ttyS0,115200

/etc/inittab:
T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100
(Try dropping the -L flag if this doesn’t work.)