Convert VM disks
qcow2 to vhd
- vbox can import vhd and it takes less space
VM images
vGateway images extensions
- .qcow2 - KVM type Virtual Machines
- .vmdk - VMware and VirtualBox and ESXi
- .vdi - VirtualBox
- .vhdx - Microsoft Hyper-V
- .vhd - Azure requires fixed size
Example commands Convert qcow2 to other formats
Convert for VirtualBox (.vdi)
Convert qcow2 to vmdk and make it VMware Workstation Player Compatible
Convert qcow2 to vmdk and make it ESXi Compatible (doesn't work with VMware Workstation Player)
Covert for ESXi 6 - Create a VMDK version 6 image (instead of version 4) (doesn't work with VMware Workstation Player)
Bash
* https://linux.die.net/man/1/qemu-img
qemu-img convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=streamOptimized,compat6 ubuntu.qcow2 ubuntu.vmdk
Convert qcow2 to Microsoft Hyper-V new vhdx format
For Azure (VHD images on Azure must have a virtual size aligned to 1 MB.)
- https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-generic#resizing-vhds
Bash
# requires qemu 2.6+
qemu-img convert -o subformat=fixed,force_size -O vpc MyLinuxVM.qcow2 MyLinuxVM.vhd
Example convert.sh script
root@aws1-cm-01:~/temp# cat convert.sh