Let’s imagine you have a .vmdk file with a virtual machine data inside and you want to migrate this disks, to a Xen source virtual machine…
There are other “converters” provided by XEN, but this time we are going to do it manually.
First, we can convert a virtual disk from preallocated to growable with this tool from VMware:
# vmware-vdiskmanager -r vmware_image.vmdk -t 0 temporary_image.vmdk
Install qemu (on Debian apt-get install qemu). You will need the qemu-img disk image manipulation tool.
Now convert the VMware format file to RAW format with:
# qemu-img convert -f vmdk temporary_image.vmdk -O raw xen_compatible.img
To import te machine in XEN, you can mount from the XEN machine a NFS or SMB resource where the RAW converted file resides and import it in XEN.
Create a machine in XEN with a disk of same amount of space as the original.
import it with xe commands like:
list the new created disks vdi with:
xe vdi-list params=all
and import it from XEN directly:
xe -s "xen_pool_master" -u root -p "root_pass" vdi-import filename="raw_image.img" uuid="UUID from above" (this will take a while to complete)
like
# xe -s "localhost" -u root -pw "rootpassword" vdi-import filename="/mnt/nfs/WilsonXP.img" uuid="03775deb-5a8e-4661-9a5e-9519fa5ac6d4"
Another way to import the image inside the VM is booting the virtual machine with a recovery distribution boot cd recovery, like wifislax ;)
Note*: Remember to set an IP after boot from the recovery CD.
mount remote resource where the image reside and restore it with dd like:
# dd if=/mnt/nfs/vmwareconv/samantha.img of=/dev/hda 9753504+0 records in 9753504+0 records out 4993794048 bytes (5.0 GB) copied, 1399.96 seconds, 3.6 MB/s
Note*: device disk will depend on the type of disk you have configured, sda (SCSI, SATA), hda (IDE), etc.
Now reboot the XEN virtual machine and boot your new migrated system.
Be careful, not all the devices will be the same, maybe you will need to update your modules or kernel, or Windows drivers just in case.