For example, run the following command to convert a QCOW2 image file to a ZVHD2 file: qemu-img-hw convert-p-O zvhd2 test.qcow2 test.zvhd2. Querying image file information: qemu-img-hw info Image file. An example command is qemu-img-hw info test.zvhd2. Viewing help information: qemu-img-hw –help.
QEMU disk image utility for Windows. It is used for converting, creating and consistency checking of various virtual disk formats. It’s compatible with Hyper-V, KVM, VMware, VirtualBox and Xen virtualization solutions.This build has been optimized for Windows Server (x64), including Windows Nano Server.
Convert a QCOW2, RAW, VMDK or VDI image to VHDX
qemu-img.exe convert source.img-Ovpc-osubformat=dynamic dest.vhd |
Subformat can be either “dynamic” or “fixed” for VHD (vpc) or VHDX.
Note: use the fixed VHD subformat for Azure, the conversion will automatically take care of the required 1MB virtual size alignment.
Check a virtual disk for consistency
Get info about a virtual disk
Run qemu-img.exe -h or see the manual page for a complete list of all supported options.
Image format | Argument for -f and -O options |
---|---|
VMDK (VMware) | vmdk |
QCOW2 (KVM, Xen) | qcow2 |
VHD (Hyper-V) | vpc |
VHDX (Hyper-V) | vhdx |
RAW | raw |
VDI (VirtualBox) | vdi |
Source code: https://github.com/cloudbase/qemu
QEMU’s project main page: http://www.qemu.org
Alternative QEMU binaries: http://qemu.weilnetz.de/
Documentation: http://qemu.weilnetz.de/qemu-doc.html#qemu_005fimg_005finvocation
Published: 16-02-2014 | Author: Remy van Elst | Text only version of this article
This tutorial shows you how to convert KVM qcow2 disk images to raw disk images.The qcow2 disk format has some decent features like encryption, compression andcopy to write support. However, the compression and the copy processes make itquite a bit slower than raw disk images. Sometimes you want to convert the diskimages so that the VM will perform better.
For me it has a performance boost. Using a RAID 1 setup with two 5900 RPM disksand the deadline
on the host and the noop
scheduler without caching on a rawimage in the guest resulted in a boost over the default deadline
scheduler ona qcow2 image on the guest:
Test command:
Default Ubuntu 12.04 vmbuilder created vm on a qcow2 image without caching andwith the deadline scheduler in the VM:
The same VM, disk image converted to raw image without caching and using thenoop scheduler in the VM:
That's quite a performance boost. The KVM host has the following result with thedd
command:
I'll convert the disk image for the example vm vm1
. Change the name and diskpaths for your setup.
First shut down the VM:
Then convert all the disk images using this command for each disk image:
Edit the VM config:
Change the disk
section to point to the new raw image:
Change the lines <driver name='qemu' type='qcow2'/>
and <sourcefile='/var/lib/libvirt/images/vm1/ubuntu-kvm/tmp20ePgc.qcow2'/>
to <drivername='qemu' type='raw'/>
and <source file='/var/lib/libvirt/images/vm1/ubuntu-kvm/tmp20ePgc.raw'/>
. Like so:
That's it. Start the VM:
If it all works, remove the qcow2 image:
To change the default disk scheduler in your VM, you can use the followingcommand:
To check the current scheduler:
Output:
Here the deadline
scheduler is being used. To change it:
Now the noop
scheduler is being used:
Remember to add this command to /etc/rc.local
to make it survive a reboot. Onubuntu you can also define it in /etc/default/grub
. ChangeGRUB_CMDLINE_LINUX_DEFAULT='quiet splash'
toGRUB_CMDLINE_LINUX_DEFAULT='quiet splash elevator=noop'
and run an update-grub2
to make it permanent