Convert Windows Vmware server 2.0.2 to KVM (Ubuntu)

Convert Windows Vmware server 2.0.2 to KVM (Ubuntu)

Be reminded that, KVM does not support Windows 98 / Windows ME well. If you have such guest, then you may need to consider something other than KVM.
If you are the first time, then you better have both the Windows host and the Linux host running… Don’t try to destroy the Windows and install the Linux on it then pray for success.
If your CPU does not have virtualization support, you better use VMware.

In Windows Host, explore to the folder containing the VM guest you want to convert.
pay attention to the virtual hard disk (vmdk) files. If you have some files name ending with numbers… e.g. winxp-00001.vmdk , winxp-00002.vmdk. Then you need to combine the files using vmware-vdiskmanager.exe. By default, it is in Program files\Vmware\ folder.
the command looks like
vmware-vdiskmanager -r winxp.vmdk -t 0 winxpbig.vmdk
or
vmware-vdiskmanager -r winxp.vmdk -t 2 winxpbig.vmdk

The -t 0 switch will create a resultant file that consist of only used space while -t 2 will produce a file consist of the whole image size.
Some says -t 0 failed, you can try -t 2.

For Windows guest, you need to do more things. Otherwise, You may receive a Stop 0x0000007B error after you move the Windows XP.
After combining the files, you can now change the guest’s disk to the combined one and boot it from Windows host to do the following steps.
1) In Windows guest, run mergeide.reg from http://support.microsoft.com/kb/314082 you also need to copy some files to system32\drivers folder. see the link.
2) In Windows guest, remove vmware tool
3) shutdown the guest

Now, you are ready to transfer the vmdk file to your linux machine…
If you do not have large enough portable device, then installing filezilla ftp server is a good way to transfer files. http://filezilla.sf.net
The files need to transfer are *.vmdk and *.vmx. And it is no harm to transfer everything if you have enough space. It is good to keep one virtual machine in one folder.

In the linux host part:
1) get Ubuntu and set it up. (http://www.ubuntu.com) you can choose VM host function.
2) install other useful things
sudo apt-get install virt-goodies qemu-kvm kvm libvirt-bin bridge-utils virt-top kvm-pxe
3) setup bridge network
3a) edit (vi) /etc/network/interfaces
3b) The address below should match your internal subnet.
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 192.168.11.3
network 192.168.11.0
netmask 255.255.255.0
broadcast 192.168.11.255
gateway 192.168.11.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

3c) restart network sudo /etc/init.d/networking restart, then you should have a bridge network ready to use. you can verify it by the command ifconfig .
4) convert vmware config files (*.vmx) to libvirt XML config file. You need to have virt-goodies installed in the previous step to use vmware2libvirt.
4a) vmware2libvirt -f winxp.vmx > winxp.xml
5) life is not perfect and so does vmware2libvirt.. you need to modify the XML to make it work. otherwise, you will receive not bootable device or no boot device error.
5a) you need to add a driver tag inside the disk tag
<driver name=’qemu’ type=’vmdk’/>

5b) For windows guest you need to use localtime clock.
<clock offset=’localtime’/>
5c) change the type to bridge in interface tag and change network=’eth0′ to bridge=’br0′ in the source tag.
<interface type=’bridge’>

<source bridge=’br0’/>

</interface>

then you can define your virtual machine config to qemu using libvirt and start it.
sudo virsh -c qemu:///system define winxp.xml
sudo virsh start winxp <— please refer to your name tag in the xml file.

If it can boot, then you can convert the vmdk hdd to qemu’s native type qcow2.
Remembert to shutdown your guest first!!!

qemu-img convert winxp.vmdk -O qcow2 winxp.qcow2
* -O is a capital letter O not a zero

after converting the image, you need to tell libvirt to use it.
you can edit the xml file then undefine the vm and then define it again.
Or directly edit the config file.
sudo virsh edit winxp
change the driver type from vmdk to qcow2
change source file to the converted file.
<driver name=’qemu’ type=’qcow2’/>
<source file=’/your_virtual_disk_location/winxp.qcow2’/>

next, we can change to use virtio driver. kvm web site says that it will increase performance a lot.
But many people find no much differece…

Leave a Reply