Configure Serial Console Access on CentOS 5

By | 05/05/2010

Today I built some virtual machines on a KVM platform (Ubuntu 10.04 Server as the host). The three virtual machines are CentOS 5, i386 and will be used primarily for internal application testing. One of the requirements for using these machines in a virtual environment was configuring back-end console access from the host. The virtual machine management tools (virsh) provide custom commands to console into your guest machines, but the guest machines need to be configured to output to the proper console. This article outlines what customizations I made to the CentOS 5 virtual machines in order to console into them from the host using ‘virsh console <guest>’


The first modifications that I needed to make were in GRUB. On CentOS the GRUB config file can be found at: /boot/grub/menu.lst. Below you’ll find the changes I made:

serial --unit=0 --speed=115200
terminal --timeout=10 console serial

I’m sure if you compare that snippet with your current configuration you’ll see the changes that I’ve implemented. Primarily the commenting of the splashimage, and the addition of the serial and terminal lines.

In addition to these changes you’ll also need to append some console configurations to each ‘kernel’ line. Here is an example:

title CentOS (2.6.18-164.15.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.15.1.el5 ro root=/dev/SLIM/root console=tty0 console=ttyS0,115200n8

Again, compare this to your current configuration. You’ll notice I’ve added console=tty0 console=ttyS0,115200n8


Finally you’ll need to make a change to the /etc/inittab file, which will allow login via the serial console connection:

S0:2345:respawn:/sbin/agetty ttyS0 115200 linux

Once these changes have been applied you should be able to reboot and connect to the console:

virsh console <guest> should then display the GRUB menu, boot output and finally a login.

8 thoughts on “Configure Serial Console Access on CentOS 5

  1. Rahul Panwar


    First of all, i want to congrats you for a very good website.

    Now my problem, i am also doing the same to configure the serial console on centos 5.4.

    But my problem is that my computer ttyS0 (com1) is not working. I installed a PCI serial card & it is installed in Centos as ttyS1.

    Now i want to do the same with ttyS1, my grub.conf is as follows:
    serial –unit=1 –speed=115200
    terminal –timeout=2 console serial
    title CentOS (2.6.18-164.15.1.el5.centos.plusPAE)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.15.1.el5.centos.plusPAE ro root=/dev/CoralVol00/CoralOS00 console=tty0 console=ttyS1,115200n8
    initrd /initrd-2.6.18-164.15.1.el5.centos.plusPAE.img
    title CentOS-base (
    root (hd0,0)
    kernel / ro root=/dev/CoralVol00/CoralOS00 rhgb quiet
    initrd /

    I also created an entry in inittab:
    S1:12345:respawn:/sbin/agetty -L 115200 ttyS1 vt100

    But i am receiving kernel panic after doing these setting. Can you help me, what i am doing wrong?

  2. Rui Gouveia

    After 2 days searching, your post saved me.

    Thank You very much!!!

    Rui Gouveia

  3. drsmooth

    Nicely succinct. Too bad the guest has to be modified. I wonder if there is a way to get this to work with the default GRUB and inittab configurations. Cheers and nicely done!

  4. Kul

    Thank you for this blog. That finally saved me today 🙂

    Greetings from Cologne/Germany

  5. Ujiro

    This was really helpful thank you so much! would have been nice to have the debian configs added to this but i ended up figuring it out.

  6. Gris Ge

    In RHEL/Centos 5, in order to let root login via serial, we also need to make sure
    /etc/securetty has ‘ttyS0’ listed.

  7. marshall

    @Rahul Panwar

    I think your issue might be related to these lines:

    serial –unit=1 –speed=115200
    terminal –timeout=2 console serial

    The switches should be –unit, –speed, and –timeout. Note the two dash characters, where your config only has one! ‘–‘ instead of ‘-‘ should at least get you moving forward.

Comments are closed.