Convert KVM image to vmdk

This Document describe only the steps needed to convert an existing kvm image into vmware compatible image to be booted off wmware. It does not include other specific steps on wmvare client creation or OS related settings.

Shutdown guest OS
Use qemu-img on VH to convert disk image : eg:

[ ]$ qemu-img convert -o compat6 -f raw vda.img -O vmdk tmp/vda.vmdk

[]$ qemu-img convert -o compat6 -f raw vdb.img -O vmdk tmp/vdb.vmdk

create dir in new Vsphere host & scp this image file over :
eg : /vmfs/volumes/5130cb52-9c9af4b0-b71e-6cae8b664570/testvm/

Ssh into vhsphere hosts & run vmkfstools command after images have been copied.

# vmkfstools -i vda.vmdk -d zeroedthick vda1.vmdk Destination disk format: VMFS zeroedthick
Cloning disk ‘vda.vmdk’…
Clone: 100% done.

# vmkfstools -i vdb.vmdk -d zeroedthick vdb1.vmdk Destination disk format: VMFS zeroedthick
Cloning disk ‘vdb.vmdk’…
Clone: 100% done.

Log on to https://vcenter:9443/vsphere-client/# to create a new vmware client referencing these newly converted disk images. Boot up guest OS and change ip address if necessary.

Notes:

Note: When running vmkfstools -i on the vmdk, this need to be done on one of the local data stores. If you attempt it on the NFS datastore it will fail. So initially copy the files to one of the local datastores to run the zeroedthick command. Then once the vm is up and running it can be moved around.

Note: The qemu-img command is a different if the image type is not raw.
eg:
qemu-img convert -o compat6 -f qcow2 vda.qcow2 -O vmdk ../virtual/vda.vmdk

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s