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)
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
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.