Convert a VMware virtual machine to KVM

Just a quick note to myself, about the process of Converting a VMware Virtual Machine machine to KVM.

Copy the VMDK files

Locate all the VMDK files, and copy to the new server.

Using the -c option to select the cipher for ssh will increase network throughput and reduce CPU usage (useful over internal LANs).

Converting from VMDK to RAW

The basic command will look like this,

But if you have multiple VMDK files, you can convert them all in a batch with this command

 Concatenate all the files

You can dump the files to a single RAW file or directly to a LVM volume or in my case a DRBD resource. And i use pv (pipe view) to have some indication on the process.

If you you know the total size of the image you can use the -s switch with pv to watch the progress bar fill.

Extra: Switching from IDE to VIRTIO

This one i have learned when i had to convert a XEN vm to KVM, so i had to do a bunch of adjustment to the vm to make it work on KVM, one of them is to re-build the kernel initrd.

  • First make sure you have a generic kernel on them VM
  • (This one i’m not sure, but i did it any way) – in the file /boot/grub/device.map, change any reference from xvdX to vdX
  • Add virtio_blk to initrd using mkinitrd (!!! your kernel version number may be different)
  • Add virtio_blk to “/etc/modprobe.conf” file, should look like
  • To add console support, edit “/etc/inittab” file and find the following section

 

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *