Setting up a serial console (as done for storage2)

This page describes how to set up a serial console on a machine (storage2 in this case). Reasons for doing so may vary; and in this case we needed to capture a kernel oops that rendered the machine unusable. This page will also discuss what needs to be done on the machine that will connect serially.

Setting up the machine to be serially connected to

1) First, support for running the console over a serial port must be enabled (note this is already true with stock redhat kernels). This assumes you know how to edit your kernel config and know how to rebuild a kernel (if need be); if you don't I find the redhat docs to be very good in this regard, check the appendix for Building a Custom Kernel in the Customization Guide for your favorite version of RedHat. You want to make sure that under "Character Devices" that "Support for console on serial port" is enabled. You can also grep for CONFIG_SERIAL_CONSOLE=y in your kernel config file. NOTE it would also probably be a good idea under "Kernel Hacking" to enable kernel debugging (at the very least).

2) Next, you need to edit /etc/inittab, and add the line (or something similar) to the section "# Run gettys in standard runlevels":

7:2345:respawn:/sbin/agetty 9600 ttyS0 vt102

Things to consider here: the 7 runs the console on virtual console 7, will this screw up accounting related to tty's if you're running X? What run levels do you want this to exist at? Do you want something faster than 9600 bps? What serial port so want to use? What terminal emulator type do you want?

3) Add ttyS0 (or the correct device for your serial port) to the end of /etc/securetty

4) You need to pass the correct options to the kernel on bootup, so I added the following to /etc/lilo.conf (the syntax is quite similar with grub) in the section for the kernel I wanted to boot and capture over the serial port: append="console=ttyS0, 9600 console=tty1"

Again, do you want something faster than 9600bps? Just make sure this entry matches your inittab entry. Don't forget to perform any necessary steps associated with modifying your boot loader (ie rerun lilo).

4) Lastly, you need to make sure /etc/sysconfig/kudzu has SAFE=yes

Setting up the machine you'll connect from

1) Pick a serial-communication-program/terminal-emulator that has the ability to communicate over a serial tty (minicom, kermit, etc).

2) You need to configure the software to communicate over the serial port at the same data rate (9600bps in ourexample), number of data bits (8 in our example), parity configuration (N for none, in our example), and number of stop bits (1 in our example). Our config under Comm Parameters in minicom are 9600 8N1, which were set under "comm Parameters".

With minicom I also had to remove the default modem dialing strings. I did this by going to the "cOnfigure Minicom" section, and choosing Modem and dialing, and removing any strings under the "Init string", "Reset string" and Dialing prefix's and suffix's.

I also saved these as the default settings on the client machine so that all I had to do when I wanted to connect was to run minicom, hit enter, and be greeted with the login prompt.

Connecting the machines together

1) Cabling - You of course need to use a null-modem cable or adapter. Attaching two PC's, you are attaching 2 DTE devices, and need to reverse the transmit and receive lines in the cable.