Enable serial console under Xen

Today I needed to see why a virtual machine under Xen was not starting up properly, and I knew it was possible to connect via a serial interface. Unfortunately this is not enabled by default (at least not in my installation). So here’s what to do.

ON GUEST MACHINE (my case is Ubuntu 12.04, using Startup system):

Add this in a new file /etc/init/hvc0.conf:

# Launch serial console for Xen

start on stopped rc RUNLEVEL=[2345] and (

not-container or

container CONTAINER=lxc or

container CONTAINER=lxc-libvirt)
stop on runlevel [!2345]
respawn

exec /sbin/getty -L 9600 hvc0 xterm

# End of file

 

ON HOST MACHINE:

In the VM’s config (my case this is /etc/xen/some_guest.cfg), add a line like this: extra=”console=hvc0 xencons=tty”. That’s hvc-zero btw.

 

Now you have to reboot the machine, possibly shutdown and re-create the VM for the Xen config to kick in.

 

Now you can connect to the console by:

xm list (to find your VM’s ID)

xm console [ID] to connect. You hit Ctrl+] to escape from it, which on my Swedish Mac means pressing Ctrl+Å.

Leave a Reply

Your email address will not be published. Required fields are marked *