Home > CentOS > Configure Serial Console Access on CentOS 5

Configure Serial Console Access on CentOS 5

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>’

GRUB

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:

default=0
timeout=5
#splashimage=(hd0,0)/grub/splash.xpm.gz
serial --unit=0 --speed=115200
terminal --timeout=10 console serial
hiddenmenu

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

/etc/inittab

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.

Categories: CentOS Tags: , , , ,
  1. May 21st, 2010 at 08:21 | #1

    Hi,

    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:
    **********************************************
    default=0
    timeout=5
    #splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    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 (2.6.18-164.15.1.el5.centos.plus)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.15.1.el5.centos.plus ro root=/dev/CoralVol00/CoralOS00 rhgb quiet
    initrd /initrd-2.6.18-164.15.1.el5.centos.plus.img
    **********************************************

    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
    July 8th, 2010 at 07:12 | #2

    After 2 days searching, your post saved me.

    Thank You very much!!!

    Rui Gouveia

  3. rwilla
    August 6th, 2010 at 00:32 | #3

    thank you…