Home VM Migration How to Convert Raw Image to Vmdk for Data Migration?

How to Convert Raw Image to Vmdk for Data Migration?

2022-10-10 | Nick Zhao

Table of contents
  • How to convert KVM raw image to vmdk?
  • How to move VM to ESXi host with Vinchin Backup & Recovery?
  • Sum Up

Virtualization technology will create virtual hard disks to store virtual machine data. They are saved with different formats by different virtualization vendors. For example, it is vmdk that is used as the virtual hard disk image in VMware environment , raw or qcow2 in KVM environment, and vhd or vhdx in Hyper-V environment, etc.

Except for directly copying data from one virtual machine to another, copying the whole virtual hard disk to another host is also a common way to migrate data. However, virtual hard disks are not always compatible in different virtual environments. As said before, virtual hard disks have different formats. When you would like to use KVM virtual hard disk on VMware ESXi host, you need to convert the image format before importing the virtual hard disk to the new host. If you also have qcow2 images on KVM host, you can convert qcow2 to vmdk to copy virtual hard disk to VMware.

How to convert KVM raw image to vmdk?

The tool you need to complete the conversion job is QEMU-img and vmkfstools. QEMU-img is a free virtual disk conversion tool for multiple kinds of virtual hard disks. It will help change the format of virtual hard disk. According to the reflection from some ESXi users, the vmdk file got from QEMU-img cannot be directly used on ESXi host. To make sure the vmdk file work on ESXi host, it is still needed to use vmkfstools to convert the vmdk file again.

The first step is to get the raw image from KVM virtual machine. You can use virsh command to get the directory of the virtual machine.

virsh domblklist kvm_virtual_machine

The next step is to install QEMU-img. Just double-click the installation package to install it on Windows computer or use commands to install it on Linux computer.

P.S. You might need the commands to install QEMU-img on Linux computer:

For Ubuntu/Debian: apt install qemu-img
For CentOS/Red Hat/Oracle: yum install qemu-img
For SUSE/OpenSUSE: zypper install qemu-img

After installing QEMU-img on computer, you need to verify whether it is successfully installed because you need to use QEMU-img command later.

Verify the installation on Windows computer: qemu-img --help

Verify the installation on Linux machine: qemu-img -v

If you see the version information of QEMU-img, it is successfully installed.

The next step is converting the raw image to vmdk for VMware.

qemu-img convert -p -f raw -O vmdk /folder/kvm_virtual_machine.raw /folder/kvm_virtual_machine.vmdk

-p: presenting the conversion progress

-f: format of the source image

-O: format of the target image

After the process is finished, you can find the vmdk file in the destination and try using it on VMware host. If you need to use it on ESXi, it is still needed the help of vmdfstools.

Use the command below to convert it again.

vmkfstools -i /folder/kvm_virtual_machine.vmdk -d thin /folder/converted_kvm_virtual_machine.vmdk

The final step to use the converted virtual hard disk is importing vmdk file to ESXi host. You can use ESXi client or vCenter to complete this. Virtual hard disk can be attached to an existing virtual machine or a newly-created one.

How to move VM to ESXi host with Vinchin Backup & Recovery?

Traditional VM migration solution needs you to do complicated jobs with many command lines while there is a systematical solution for virtual machine management and migration.

Vinchin Backup & Recovery is a professional backup and disaster recovery solution for multiple virtualization platforms including VMware vSphere, Red Hat Virtualization, oVirt, OpenStack, Oracle Linux KVM, etc. (Native KVM is not supported for now) It will let you manage the heterogeneous virtual environment by adding all the hosts to the same system and then you can easily move virtual machine.

Vinchin Backup & Recovery

The process of moving virtual machine between different hosts is: add both source host and destination host to Vinchin backup system > agentless backup the target VM > select the backup of the VM to restore it on ESXi host.

The steps to converting raw image are not necessary because it will be automatically completed in the background. You will directly get an entire virtual machine on the ESXi host.

Thousands of companies have chosen Vinchin Backup & Recovery to protect and manage their virtual environments and you can also easily begin with this convenient system. Just click the button to get the installation package and use it with a 60-day full-featured free trial.

Sum Up

Different virtualization vendors used different formats for virtual hard disks like KVM platform's raw image, VMware's vmdk file, etc. Virtual hard disks are like physical hard drives, containing most of the data so they are important in virtual machine data migration. IT administrators can use QEMU-img to convert image from raw to vmdk to use KVM image on VMware.

You can also use Vinchin Backup & Recovery to easily protect and manage heterogeneous virtual environment. Don't miss the free trial.

Share on:

Categories: VM Migration