How to set up a virtual KVM/VNC console on your OVH server

Want to install your own image on a OVH Kimsufi or SoYouStart server? Want to install an official image on your server instead of the pre-built OVH OS templates? Want to encrypt the home directory at install-time? Want to use RAID 5 using mdadm on one of those SSD equipped SoYouStart servers? Or do you want to use a more refined, custom partition layout which is not supported by the OVH partitioner? And you want this without having access to or having to pay for a KVM console?
Continue reading

KVM VM waits forever / stuck at kernel selection screen

If a KVM virtual machine has not been properly shutdown, it may wait forever at the boot up kernel selection screen for user input. You won’t see any output when trying to virsh console into the VM from the host. You have to fire up a remote VNC session in order to press enter.

In Ubuntu Server you can override this behaviour by adding the following line to /etc/default/grub:

GRUB_RECORDFAIL_TIMEOUT=2

Don’t forget to run update-grub afterwards.

Enable KVM guest console access in Ubuntu using the virsh console command

Usually, my first step after setting up a new Ubuntu guest is to enable console access in order gain shell access on the newly created VM.

Step 1 – Activate the serial console in the guest

nano /etc/default/grub

Change the GRUB_CMDLINE_LINUX_DEFAULT to:

GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,38400n8 console=tty0"

Don’t forget to update Grub

update-grub

Step 2 – Create the serial console in the guest

cp /etc/init/tty1.conf /etc/init/ttyS0.conf
nano /etc/init/ttyS0.conf

Edit ttyS0.conf and replace the tty1 with ttyS0 in the last line so it will read something like “exec /sbin/getty -8 38400 ttyS0”.
Reboot the VM.

Step 3 – Log in from the host

virsh console myvm

This is it! You just gained console access to your VM.

Tip: To exit the console, hit CTRL-]. It doesn’t matter where the ] is located on your keyboard, you have to press the key below the <BACKSPACE> key and on the left side of the <ENTER> key.