Welcome to my world

Migrating from VMware Server to KVM on Ubuntu

After being let down by VMware one too many times (this time after upgrading Ubuntu to the latest beta and finding out that kernel 2.6.30+ is not supported), I decided to move on to KVM. After all, my server has full virtualisation support in the CPU so why not put that to good use.

I’ve started off by making sure virtualisation support is enabled in the BIOS. In my case it was nowhere to be found and a quick search for the MSI KA780G (MS-7551) showed that users had varying experience finding the feature but everyone seemed to agree that a BIOS upgrade should help (most of the time). A quick ‘lshw’ showed that I indeed was using the 16.0 version of the BIOS which is more than a year old.

Next, how to flash the BIOS? I do not (like the guide from MSI suggest) have a floppy drive installed in my server nor do I have Windows installed. Luckily, updating the BIOS of the KA780G is pretty easy as it is supported by the Linux programmer ‘flashrom’:

apt-get install flashrom    
flashrom -r backup.bin
flashrom -w newbios.bin

Warning: the last command actually programs the new BIOS into your computer. Make sure you have the right BIOS for your motherboard and do not interrupt the flashing.

On a side note: The 16.4 BIOS found on the support site did nothing for my AMD 5000+ CPU, in this thread, a helpful user uploaded an unsupported version which forcefully enables Hyper-V (the file is called A7551ACI rather than A7551AMS). The download requires registration on the forums.

If you finally manage to get it working, it is found under “Advanced Processor Features” –> “SVM Support” (SVM = Hyper-V). Enable it and reboot.

On a side note: I enabled HPET also, which stands for High Precision Event Timer, an upgraded version of the old RTC timer and useful for boosting overall performance (thanks to better timing control).

After rebooting I installed “kvm” and the module “kvm-amd” loaded without a hitch. The current “lshw” output is shown below. Notice how the name of the board changed from “MS-7551” to “CI-7551”. I guess “CI” stands for “Custom Image. Also note that the capabilities list the svm feature (note: the svm feature is visible on the CPU even if the BIOS disabled it – you simply can not use it without BIOS support).

       description: Motherboard
       product: KA780G (CI-7551)
       physical id: 0
       version: 1.0
       serial: To be filled by O.E.M.
       slot: To Be Filled By O.E.M.
          description: BIOS
          vendor: American Megatrends Inc.
          physical id: 0
          version: V16.0B2 (06/08/2009)
          size: 64KiB
          capacity: 960KiB
          capabilities: isa pci pnp apm upgrade shadowing escd cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer int10video acpi usb ls120boot zipboot biosbootspecification
          description: CPU
          product: AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
          vendor: Advanced Micro Devices [AMD]
          physical id: 4
          bus info: cpu@0
          version: AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
          serial: To Be Filled By O.E.M.
          slot: CPU1
          size: 2400MHz
          capacity: 2600MHz
          width: 64 bits
          clock: 200MHz
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp x86-64 3dnowext 3dnow rep_good extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch cpufreq

Next up, I converted the VMware disk holding my CentOS based server in two steps: first I converted the 2GB files into one large file holding the entire virtual hard drive. Next, I used “qemu-disk” to convert this VMware based format into something KVM can use:

root@sportlaan-htpc:/mnt/media/virtual_machines/# vmware-vdiskmanager -r Sportlaan_WebMailFtp_Server.vmdk -t 0 Sportlaan_Server.vmdk    
Creating disk 'Sportlaan_Server.vmdk'
  Convert: 1% done.

  Convert: 100% done.
Virtual disk conversion successful.
root@sportlaan-htpc:/mnt/media/virtual_machines/# qemu-img convert Sportlaan_Server.vmdk -O qcow2 Sportlaan_Server.qcow2

Next up is the conversion from the VMware virtual machine description to something qemu can use. We can use the “virt-goodies” package for this:

root@sportlaan-htpc:/mnt/media/virtual_machines/# vmware2libvirt -f Sportlaan_WebMailFtp_Server.vmx > server.xml    
root@sportlaan-htpc:/mnt/media/virtual_machines/# virsh -c qemu:///system define server.xml
Connecting to uri: qemu:///system Domain Sportlaan_WebMailFtp_Server defined from server.xml

The virtual machine is now imported into “/etc/libvirt/qemu” so it can be used by libvirt. The only thing left to do it tweak the setup a little. Start by editing the generated XML file in the VMware directory to use the new KVM disk instead and make sure to define it again (because the same name is used, you simply redefine the host): “virsh -c qemu:///system define server.xml”.

Also, you might want to tweak the VNC settings to your liking: by default it uses an available port for the localhost only. Furthermore, I switched the network interface to bridged mode so the VM will be part of the network. Do this by renaming type from “network” to “bridge” and replace “” with “”. Also, you need to define a “br0” bridge device to replace your “eth0”: bridged ethernet devices will use this “br0” device to communicate their data to “eth0”. See also this guide.

Now all that is left is to issue “virsh start YourServer” to fire up the new virtual machine. Note that you might have some issues to solve; like setting up new drivers in your guest VM.