This is an old revision of the document!
qemu-img convert: raw, qcow2, qed, vdi, vmdk, vhd
Image format | Argument to qemu-img |
---|---|
QCOW2 (KVM, Xen) | qcow2 |
QED (KVM) | qed |
raw | raw |
VDI (VirtualBox) | vdi |
VHD (Hyper-V) | vpc |
VMDK (VMware) | vmdk |
This example will convert a raw image file named image.img to a qcow2 image file.
qemu-img convert -f raw -O qcow2 image.img image.qcow2
Run the following command to convert a vmdk image file to a raw image file.
qemu-img convert -f vmdk -O raw image.vmdk image.img
Run the following command to convert a vmdk image file to a qcow2 image file.
qemu-img convert -f vmdk -O qcow2 image.vmdk image.qcow2
root@manu:~# qemu-img create -f qcow2 /Virtual_srv/qemu/rocky9_01_disk.img 20G Formatting '/Virtual_srv/qemu/rocky9_01_disk.img', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16 . root@manu:~# du -sh /Virtual_srv/qemu/rocky9_01_disk.img 196K /Virtual_srv/qemu/rocky9_01_disk.img root@manu:~# qemu-img info /Virtual_srv/qemu/rocky9_01_disk.img image: /Virtual_srv/qemu/rocky9_01_disk.img file format: qcow2 virtual size: 20 GiB (21474836480 bytes) disk size: 196 KiB cluster_size: 65536 Format specific information: compat: 1.1 compression type: zlib lazy refcounts: false refcount bits: 16 corrupt: false extended l2: false Child node '/file': filename: /Virtual_srv/qemu/rocky9_01_disk.img protocol type: file file length: 192 KiB (197120 bytes) disk size: 196 KiB
qemu-system-x86_64 -k fr -m 512 -drive file=/Virtual_srv/qemu/rocky9_01_disk.img,format=qcow2 -boot d -cdrom /home/manu/Downloads/Rocky-9.4-x86_64-minimal.iso -nographic -netdev user,id=mynet0 -device e1000,netdev=mynet0
virt-install \
manu@manu:~$ virsh domiflist rocky9 Interface Type Source Model MAC ------------------------------------------------------------- vnet0 network default virtio 52:54:00:56:fe:1e manu@manu:~$ virsh list Id Name State ------------------------ 1 rocky9 running manu@manu:~$ virsh shutdown rocky9 Domain 'rocky9' is being shutdown manu@manu:~$ virsh list Id Name State -------------------- manu@manu:~$ virsh start rocky9 Domain 'rocky9' started manu@manu:~$ virsh list Id Name State ------------------------ 2 rocky9 running
Review the provision from the Host OS.
manu@manu:~$ virsh domblklist FMGinternal Target Source ---------------------------------------- hda /srv/VMs/fmg.qcow2 hdb /srv/VMs/fortimanager.qcow2 vdb /srv/VMs/fortimanager2.qcow2 manu@manu:~$ virsh domblkinfo FMGinternal vdb --human Capacity: 80.000 GiB Allocation: 196.000 KiB Physical: 193.250 KiB