Ubuntu 12.04 server serial console how-to  Friday 18th May 2012, 20:13

I've been waiting for a few weeks for a fairly unusual part for my server to arrive, and this morning low-and-behold a small package from Hong Kong had arrived. Nothing too exciting, simply an Asus serial port header cable so now my server has a serial port! My old connector is in my main PC used exclusively for my serial IR receiver for use with LIRC and MythTV.

Now why would I want one in my server as well? I do sometimes need to do some maintenance and occasionally for whatever reason it doesn't boot and gets itself caught up (not so much since I installed the latest iteration of Ubuntu). Up until recently I had a monitor (old 14" CRT taking up way too much space) and a keyboard constantly connected. Now as my server is my old desktop PC it takes a PCI-Express graphics card. I don't actually have any cheap or rubbish old graphics card in this format, and therefore have to put a fairly competent power hungry graphics card in there, all just to see my boot-loader and to occasionally cancel disk scans; which obviously makes little sense at all.

If I redirect the main console output on my server to the serial port, connect my old laptop and log-in to the console session I can manage my server with nothing more than a null-modem cable; brilliant!

It took me a short while to find the instructions for getting this working on Ubuntu 12.04, as most content I found unsurprisingly refer to older instances or the server grade distributions such as Red Hat. I followed the instructions from this site (on the Ubuntu community), but I will summarise what I actually did for completeness.

First off we edit the following file (which in my case didn't exist):

Code: /etc/init/ttyS0.conf# ttyS0 - getty
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc or RUNLEVEL=[2345]
stop on runlevel [!2345]

exec /sbin/getty -L 115200 ttyS0 vt102

Now that we have the start-up script for the serial console we start the service, from this point the serial console should already work:

Code:sudo start ttyS0

The next stage is to modify GRUB so that the boot-loader will also be passed along the serial port so if for whatever reason I wish to see the boot-loader then I can. On the site I provided above they gave several options that need be changed in the following file, however I have only provided the modifications I actually made for brevity.

Code: /etc/default/grubGRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200n8"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

The next step in the tutorial provides the process for getting the kernel output through the serial port, however I didn't need to make these modifications as it seemed to work by default.

Now that was pretty simple and works very nicely, the next step would be to build/acquire a couple of serial-RJ45 adapters allowing me to pass the console over a network cable. With this I could patch my server output to a network port in whichever room in the house I may be. Obviously I could just use an SSH session to connect, but if networking isn't brought up by my server then I have the means to fix the networking issue without lugging a monitor up the stairs! The only limitation to this system that I can see is the lack of BIOS support, which is a shame. Unfortunately with a conventional desktop PC acting as a server it doesn't have all of the extra features that we might expect in a more expensive bespoke device. If the motherboard supported the BIOS over serial feature then I could maintain the system including upgrading the OS on my 6-monthly cycle and take disk-images without every connecting a monitor again.

Previous Blog Post Next Blog Post