Linux Serial Console

All of the machines we have in our production environment are completely headless systems which makes sense since they are about 150 miles from where our main office is.

The beauty of a Sun Workstation is that, in following with the model of “The Network Is The Computer”, if there is no keyboard plugged in, the system directs all output via the serial port.  When I say “All”, I mean “all“.  So, if I want to shut down the machine (without physically powering it off), I can bring the system down to the “ok” prompt, which, for the Windows world, is the equivalent of being at the BIOS level.

Now that we have our first linux server in place, obviously we wanted to have “console” access to the machine.  However, one quickly realizes that with a PC-based system, the equivalent of the Sun based “console” is really not easily attainable.

One of the steps in the right direction is setting Linux up such that it directs its output via the serial console port.  This is helpful when you need to gain direct access to the system if the system goes off of the net for one reason or another (of course, you need a console server to provide you with access).

In Linux, it is actually pretty easy.  I emailed the general steps to a colleague of mine:

Here's the grub.conf file I created to output to both the serial console
and the primary video display.  The key lines are:
serial --unit=0 --speed=9600
terminal --timeout=2 serial console
And appending "console=tty0 console=ttyS0" to the kernel arguments.
Supposedly, the ordering of those arguments is important.  The last
argument is where single user mode and kernel messages are directed to,
so, in this case, the system will work with ttyS0 as if it were its
primary interface, and tty0 is then treated as a secondary interface. (I
found this buried in the following article:

Also, I added the following line to /etc/inittab:
S0:12345:respawn:/sbin/mgetty -b -r -s 9600 -p "Login: " ttyS0

And I added "ttyS0" to the end of /etc/securetty.  That's supposed to
allow root to log in via the serial port.

With that done, I had (and still have) a serial console connection to
the headless linux box.


~]# more /etc/grub.conf
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/md1
#          initrd /initrd-version.img
serial --unit=0 --speed=9600
terminal --timeout=2 serial console
title Fedora Core (2.6.17-1.2139_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.17-1.2139_FC4 ro root=/dev/md1 rhgb quiet
console=tty0 console=ttyS0
initrd /initrd-2.6.17-1.2139_FC4.img
title Fedora Core (2.6.17-1.2141_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.17-1.2141_FC4 ro root=/dev/md1 rhgb quiet
console=tty0 console=ttyS0
initrd /initrd-2.6.17-1.2141_FC4.img

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.