Tech Tip: Setup Your Linux Server to Use a Serial Console


Do you have a linux server without a keyboard or monitor? Need to administer the server on-site but don't want to lug over a monitor and keyboard (or kvm)? Then setup the server to output the console to a serial port and use screen/minicom (Hyperterminal or putty in Windows) to console into the server over a serial cable.

To set this up, you need to edit /etc/inittab to tell it to start a terminal on the serial port for the console. If you want to see the kernel load and see all the services start then you also need to configure grub to use the serial port as well.

Edit /etc/inittab and add the line starting with "co" to the file (substitute the device name of your serial port for ttyS0 below):

co:2345:respawn:/sbin/agetty ttyS0 57600 vt100-nav  # ADD THIS LINE
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

To watch the kernel load (and all the services) you must configure grub to enable the console option in the kernel on boot. Edit /boot/grub.conf and add the "serial" and "terminal" lines below, and modify the "kernel" line to include the console specification:

serial --unit=0 --speed=57600
terminal --timeout=5 serial console
title CentOS (2.6.9-55.0.2.EL)
   root (hd1,0)
   kernel /vmlinuz-2.6.9-55.0.2.EL ro root=/dev/VolGroup00/LogVol00 console=ttyS0,57600n8
   initrd /initrd-2.6.9-55.0.2.EL.img

To connect to the server just hook a serial cable from your laptop to the server. Set the speed to 57600, no parity and 8bits. Boot up the server, you should see kernel output, services load, and finally a login prompt. After you disconnect you can easily re-connect and log in: just fire up your terminal emulator, connect your serial cable, hit enter a few times and you should get a prompt to log in.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Folks, I am new to the

Anonymous's picture

Hi Folks,

I am new to the open source world, I have got a linux however, as mentioned by Jul 07, 2009 By Josh Hiner I can not see the box so I can not change “edit /etc/initta” what are other options for me.

Please advice, I am using both Putty and TeraTerm, with recommended specs on COM4


It'd be really slick if

Anonymous's picture

It'd be really slick if there exists a serial-to-USB cable. I'd love to be able to plug in when there's a problem that takes the system off the network, but most laptops these days don't have a serial port...

USB to Serial

Paul B's picture

"It'd be really slick if there exists a serial-to-USB cable. I'd love to be able to plug in when there's a problem that takes the system off the network, but most laptops these days don't have a serial port..."

There are many USB to serial connectors on the market.

Google is your friend.

Here is one of the better connectors:

- Paul

I recommend to set up line

ran's picture

I recommend to set up line speed not 57600, but 9600
This number is more typical in many situation of same using of serial port:
Cisco, Solaris ...

Cable Length

Anonymous's picture

This article omits mentioning maximum serial cable lengths.

The length of serial cable will determine the max communication speed. ... Just in case someone was thinking of running a serial cable from one room to another. (Google serial cable lengths and speed for more info.)

And, for those curious how some can get a copy/past of those nasty kernel oops, well, this is how they did it.

(This is also commonly used for debugging LinuxBios/Coreboot project. ;-)

This is probably one of the coolest things I've seen that can be done with Linux vs Windows.

remembering sun serial console

thogarty's picture

for those who have worked with sun hardware, serial console is enabled at a lower level allowing the OS to be installed or boot firmware settings (bios in pc speak) to be modified using a serial terminal.

does anyone know of pc hardware that supports a serial console before the OS is loaded like this? it's similar to the way network equipment can be configured (cisco, etc).

thanks for the tip, indeed another handy way to access systems in the data center or elsewhere where a gui console is not easily available.

Will depend on your BIOS.

Frederic Roussel's picture

Will depend on your BIOS. Some server BIOSes allow to be configured to have console to serial instead of VGA.

Now, if you really badly want it, there is some really cool, though not totally obvious to deploy, replacement for the VGA console in the form of a BIOS extension:


Very Cool

blak111's picture

I really like this tip. I have a lot of headless servers that I have to bring a monitor to when something goes bad (usually a mistake on my part). I didn't realize how easy it was to set this up.