Serial console for Ubuntu server 10.04 KVM guests

0.00 avg. rating (0% score) - 0 votes

The virt-manager VNC screen is fine for LAN connections, and good for running graphical sessions. X is not installed on Ubuntu server by default, and VNC is really bad over slow links even for text console. I like to configure serial console for all my virtualized guests, because with it, I can simply ssh into the virtual machine host, and run “virsh console <guest-name>” to get a working console. Very nice for fixing broken network connections or file systems, or any kind of boot problems. And I can do it using just my cell phone, ssh over 3G connection from anywhere!

In Ubuntu, there are three things you may want to configure to use serial console:

1. GRUB boot menu
2. Kernel and init messages
3. Pseudo tty to log in and get shell

Serial device for your virtual guest

But first things first: you must add a serial device for your guest machine in order to be able to use the serial console.

In virt-manager it is as easy as adding a new hardware device, type Serial, and device type “Pseudo TTY (pty)” into the machine configuration. No further configuration needed, just add the device and that’s it.

In the libvirt XML configuration file the device should look something like this:

The GRUB boot menu, Linux kernel, and system init messages

With GRUB 1, it was possible to get the GRUB menu simultaneously over serial and graphical VNC console. Unfortunately I haven’t found a way to do that with GRUB 2. Linux kernel fortunately does output messages both to the serial and VNC console if so configured. The upstart init will output its’ messages to whatever the kernel is configured to do.

To make the GRUB menu and kernel messages show up over serial console, you need to edit the /etc/default/grub file and run update-grub afterwards. The changed or added lines are marked with bold below:


Run update-grub after making the changes. During the next reboot, you will be able to choose your kernel using the GRUB menu, or run any grub commands, using the serial console.

The GRUB menu will show up only on the serial console, while the kernel and init messages will show up on both serial console and the graphical screen.

Detailed explanation

Here’s a description of what each of the changes mean:

This simply enables the GRUB menu, which is hidden by default in Ubuntu.

These two lines control the Linux kernel behaviour. This will append the necessary kernel command line options to all kernels, both normal and rescue mode. With the two console= options, the messages will go to both tty0 (VNC screen) and ttyS0 (serial console).

Also upstart init will show messages on both, and single user mode (runlevel 1) will work on both (the rescue mode root shell).


3 thoughts on “Serial console for Ubuntu server 10.04 KVM guests”

  1. I am trying to access the console of a virtual machine on the host on which it is running, I made all the above changes to the /etc/default/grub, and tried:
    virsh console vm-name
    it shows the following error: Escape character is ^]

Leave a Reply