Convert vm to vhd azure

mrhoang2610

New Member
Apr 23, 2020
1
0
1
34
I have 2 VMs on proxmox
I want migrate VMs to Azure Cloud use vhd format.
How to convert vm (qcow2) on proxmox to vhd format?
 
The only possible way to convert is the drive (correct me If Im wrong).

You need to use in shell or ssh the following package: qemu-img
With this you can convert your drive format to your desired (like now from qcow2 to vhd)

Go to the directory where your VM is stored and this is an example command:

qemu-img convert -f qcow2 -O vpc disk.qcow2 disk.vhd
 
The conversion works, the problem is that the disk size is not maintained when converting to .vhd from .qcow2.
Azure requires that the disk be exactly a 1 MB increment, and the conversion process always adds 512 KB.
Anyone figure out how to work with the Azure 1 MB increment requirement?
Thanks
 
Litle late but this works for me:

qemu-img convert -f vmdk -O raw input.vmdk output.raw
MB=$((1024 * 1024))

size=$(qemu-img info -f raw --output json "output.raw" | gawk 'match($0, /"virtual-size": ([0-9]+),/, val) {print val[1]}')
rounded_size=$((($size/$MB + 1)*$MB))
qemu-img resize output.raw $rounded_size

qemu-img convert -f raw -o subformat=fixed,force_size -O vpc output.raw final.vhd