Setting Up a Serial Console on Linux


Tomorrow my new server (1U, rackmount) moves into its new home. There's still much to do, but I've been focusing on things that are easier to do while its in my machine room in my basement, like configure RAID-1 on the two 80Gb disks. The other task I wanted to get done before I installed it remotely was get the serial console working. The serial console enables start-up and configuration of the machine using a serial cable plugged into a laptop instead of having to haul a monitor and keyboard around. You have to do that at least once to configure the IP address when you move to a new home. The configuration was pretty straightforward. Here's what I did:

I pretty much followed the instruction in the serial console HOWTO. The primary steps are:

  1. Set up the serial port
  2. Change the boot loader to boot from the console and pass the right parameters to the kernel
  3. Make sure a getty is running on the right serial port
  4. Change any configurations for other programs that might get in the way

The HOWTO can seem daunting at first because it designed for every contingency. Just remember you won't have to do everything that's there, although you'll probably have to read most of it to figure out what you do have to do. Here's what I had to do to make it work on my box (Redhat 9.0 with the GRUB bootloader):

First, I disabled serial port 2, to ensure that its interrupt (which is shared with serial port 0 on Intel platforms) doesn't interfere with serial port 0. Add these lines to /etc/rc.serial (create it if necessary):

# Disable /dev/ttyS2 so interrupt 4 is not shared,
# then /dev/ttyS0 can be used as a serial console.
setserial /dev/ttyS2 uart none port 0x0 irq 0

Next I configured the boot loader (GRUB in my case) to use the console and pass parameters to the console which cause it to use serial port 0 as its console:

default=0
timeout=10
# splashimage=(hd0,0)/grub/splash.xpm.gz
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console
title Red Hat Linux (2.4.20-8)
     root (hd0,0)
     kernel /vmlinuz-2.4.20-8 ro root=/dev/md0 console=tty0 console=ttyS0,9600n8
     initrd /initrd-2.4.20-8.img

Configuring getty consists of adding a line to /etc/inittab to spawn a new shell on the console. I chose to use /sbin/agetty rather than plain old getty since you can pass the configuration in as parameters rather than putting it in the gettydefs file:

co:2345:respawn:/sbin/agetty -h -t 60 ttyS0 9600 vt102

I had already change the inittab so that X doesn't spawn by changing the 5 to a 3 in the id line:

id:3:initdefault:

Finally, there are a few things specific to RedHat which need to be taken care of.

There were two other things that needed to be done to make the box datacenter ready (or at least as ready as I know how to make it). The first is to disable error checking in the BIOS for the keyboard (since no keyboard will be connected and the BIOS will hang otherwise). The second is to check the power management parameters to ensure that the suspend mode is turned off and the box is set to return to the "on" state after a power failure. There's UPSs and generators at the datacenter, but I've seen too many boxes lose power in environments that are "fully conditioned" to trust them completely.

Once done, I tested the configuration by rebooting the box, watching what happens in a simulated "unattended reboot" and ensure that it comes up. Next I performed a simulated power failure (i.e. pulled the power cord) to ensure that the toggle switch defaults to "ON." Finally, I checked to make sure that I could log in at the serial console after all of this.

Of course, you will need to read and understand the HOWTO to determine how it pertains to your particular system, but don't be dissuaded by its size. Most of it is explaination and multiple configurations based on system particulars. There's plenty of tutorial material and other helps on serial lines, security, and so on. Once you've got software RAID configured, the OS installed, and the serial console working, you can pretty much do the rest of the job remotely. More on that later.


Please leave comments using the Hypothes.is sidebar.

Last modified: Thu Oct 10 12:47:20 2019.