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?

The first step is to boot the server in rescue mode. Once the server has been booted in rescue mode, log in with the credentials sent to you via email and download an image of the OS you plan to install. I’m using a 64-bit Ubuntu minimal image here:

root@rescue:~# wget -P /tmp

Install a QEMU/KVM package on the server or download a pre-built one from here:

root@rescue:~# wget -qO- /tmp | tar xvz -C /tmp

Now, make the QEMU VNC server available on localhost:5900. I’m specifying all three block devices (sda, sdb, sdc) in my OVH server for QEMU in the example below. Here’s a gotcha: since -hdc won’t work together with the -cdrom parameter (it’s a documented feature…) I have to use -hdd for the third SSD.

root@rescue:~# /tmp/qemu-system-x86_64 -net nic -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443 -m 1024M -localtime -enable-kvm -hda /dev/sda -hdb /dev/sdb -hdd /dev/sdc -vnc -cdrom /tmp/mini.iso -boot d

If you’re getting an error message saying Could not open '/dev/sdc': No such file or directory you probably have less than three drives available in your server and you need to modify the QEMU start parameters accordingly.

Open a secure SSH tunnel to your remote server from your local computer:
ssh -L 5900:localhost:5900

Now you should be able to open a VNC client using the address localhost:5900 which will be forwarded to your remote server using the SSH tunnel.


Once you’re done installing the OS, QEMU will boot the newly installed OS. Make sure to validate/correct the /etc/network/interfaces file at this time. A basic, IPv4 network configuration for an OVH server running Ubuntu or Debian could look like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

I highly recommend setting the GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub to GRUB_CMDLINE_LINUX_DEFAULT="biosdevname=0 bootdegraded=true"
Don’t forget to run update-grub afterwards. When everything has been set up properly, change the boot mode in OVH’s control panel back to hard disk and root@rescue:~# reboot. Once the server is up, log in with the credentials you specified at install-time.

If something goes wrong you can always boot in rescue mode and restart QEMU using the command above. Don’t specify the -cdrom and -boot parameter in this case. Or, you could just use this one-liner on your local computer:

ssh -L 5900:localhost:5900 'killall qemu-system-x86_64 ; wget -qO- /tmp | tar xvz -C /tmp && /tmp/qemu-system-x86_64 -net nic -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443 -m 1024M -localtime -enable-kvm -hda /dev/sda -hdb /dev/sdb -hdd /dev/sdc -vnc'

Again, make sure to supply the right amount of block devices. The command above only works when sda, sdb and sdc are available.


  • Not tested with hardware RAID controllers. However, mdadm works just fine.
  • The CPU has to support the VMX (Intel) / SVM (AMD) virtualisation extensions. Check with /tmp/kvm-ok when in doubt. Kimsufi Celeron/Atom servers are most likely SOL since they don’t support these extensions.
  • I used Debian and Ubuntu images for testing but it should work with other OS (especially Linux OS) too. Let me know in the comments!
  • Once you modify /etc/network/interfaces and reboot back into the VM, you will loose network access in the VM. Forwarding to the host only works with the default DHCP settings.

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

  1. When I follow this at the end my server will boot itself back into rescue mode (even when I switch it back to HD). I’ve tried reinstalling the linux kernel to “fix” the rescue one but it always kicks back to Rescue mode. Any thoughts?

  2. I had to use the command “modprobe kvm-intel” to allow the “-enable-kvm” switch to work on my OVH VPS. As well, I switched the drives to vda and vdb, accordingly.

    Since I was also connecting from my Windows machine, I setup the tunnel in Putty. I found the instructions online, but basically look for Tunnels in the SSH settings under Connection. I then used TightVNC to connect as described.

    Thank you for this awesome guide.

  3. Sébastien Dinot

    Dear Jan,
    Your guide has enable me to reinstall a fresh Debian on an OVH server without losing 6 To of data stored on its disks. Many thanks!
    Two remarks:
    1. QEMU and the qemu-system-x86_64 command are available on the KVM system provided by OVH, no extra package is required.
    2. An Apache HTTPd server is launched by OVH to permit some hardware checks and diagnosis from a web browser. The user must stop this server (service apache2 stop) before launching the QEMU command. Otherwise, the QEMU command fails to setup the port forwarding.

  4. I’ve got an error:
    qemu-system-x86_64: -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443: could not set up host forwarding rule ‘tcp::443-:443’
    qemu-system-x86_64: -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443: Device ‘user’ could not be initialized
    Any idea why?

  5. How do i get this to work with Windows ? Everything set up but after i switch the mode to hard disk and reboot it doesnt come online, must be a network issue…

  6. This is great for installing but for some reason when I set the server to reboot using hard drive, it never appears as online, and I get a message from OVH saying there has been a problem and an engineer will intervene.

    Previous support ticket said the screen is on and asking for a password so I suspect there is an issue initialising the network card. If I find out anything else I’ll post in the comments.

      • I think this is a result of a botched network config as well. For instance, if you’re not using biosdevname=0 then your eth0 may be named p6p1 or something like that.


      • Yes, I did indeed have a static config. I reinstalled and started from scratch and it all works well now – thinking back I think it might well have been that I missed the biosdevname=0 which is a bit embarrassing.

    • First: Thanks for this guide! A lot better then debootrapping ;-)
      Second: When installing Ubuntu/Debian it might also be the persistent udev rules that brings up different ifaces because of different MAC address(es) once booted the real server.
      To fix that , just delete /etc/udev/70-persistent-net.rules and reboot.
      Also if you have a server with 10GB NIC’s, make sure you load the right driver (‘#modprobe ixgbe’ in my case)

Comments are closed.