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 http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/mini.iso
Install a QEMU/KVM package on the server or download a pre-built one from here:
root@rescue:~# wget -qO- /tmp http://cdn.trick77.com/vkvm-latest.tar.gz | 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 127.0.0.1:0 -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 email@example.com -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 address 18.104.22.168 netmask 255.255.255.0 network 22.214.171.124 broadcast 126.96.36.199 gateway 188.8.131.52
I highly recommend setting the GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub to
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
-boot parameter in this case. Or, you could just use this one-liner on your local computer:
ssh firstname.lastname@example.org -L 5900:localhost:5900 'killall qemu-system-x86_64 ; wget -qO- /tmp http://cdn.trick77.com/vkvm-latest.tar.gz | 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 127.0.0.1:0'
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-okwhen 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/interfacesand reboot back into the VM, you will loose network access in the VM. Forwarding to the host only works with the default DHCP settings.