Changing VirtualBox to KVM/ConVirt

As I have mentioned earlier VirtualBox and PHPVirtualBox didn’t work out for me and I have since moved on to KVM (QEMU) and ConVirt - which so far works out pretty well.

Uninstalling VirtualBox

First one needs to uninstall VirtualBox as it is no longer needed

$ sudo apt-get remove virtualbox-4.1
$ sudo apt-get autoremove

Installing KVM

KVM is very easy to install, even if you didn’t select the virtualization profile when you installed Ubuntu Server. The “magic” command to install KVM is:

$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Installing ConVirt

First you need to enable the partner repositories on your Ubuntu installation. Edit /etc/apt/sources.list and uncomment the following lines:

deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner

Then run the following commands to install ConVirt version 2

$ sudo apt-get update
$ sudo apt-get install convirt2 convirture-tools
$ sudo apt-get install ssh kvm socat dnsmasq uml-utilities lvm2 expect

Install required dependencies for convirt-tool:

$ sudo convirt-tool install_dependencies

To have a virtual machine connect to a network, bridge setup is required. With virtualization platform installation, depending on the version, you would have either virbr0 or eth0 or br0 setup. You can verify this using the brctl show command. If you do not have any bridge, convirt-tool can set up bridges for each network interface.

$ sudo convirt-tool setup

Once this is done you can start the ConVirt console:

$ sudo /etc/init.d/convirt2 start

The web interface can be reached at http://localhost:8081/ or the IP / hostname of your choice.

Setting up distributed file system for the virtual system images

ConVirt stores the virtual system images in /var/cache/convirt and the images needs to exists on all servers for system migration to work. See a separate blog post why this is a very cool thing.

Anyway, I already have GlusterFS installed and created a new share very much like the /home share I already have but this time share /export/convirt and mount it on /var/cache/convirt. Once that is done all my 3 systems share the same data and can perform system migration, both live and offline.

Converting VirtualBox and VMWare virtual machines to KVM/QEMU

If you haven’t noticed VMWare has become the de-facto standard when it comes to virtual machines (of all the virtual systems I have imported only ZeroWine seems to be shipping as a QEMU image). It can be useful to convert the .vmdk file to a .raw (or any other format that KVM/ConVirt supports). This I do using the qemu-img utility:

$ qemu-img convert virtualmachine.vmdk -O raw virtualmachine.raw

Then I create a new virtual machine using ConVirt and replace the created virtual hard disk with the converted one, something in the style of:

$ sudo cp $HOME/virtualmachine.raw /var/cache/convirt/vm_disks/virtualmachine.disk.xm

There is a conversion utility that supposed to solve this, but I didn’t get it to work. Maybe another time…

1 comments:

Anonymous said...

were you able to get that conversion utility working ?
(virtualbox to kvm)

Post a Comment