Language and Page Formatting Options
14.6. Converting an Existing Image to Another Format
convertoption is used to convert one recognized image format to another image format. For a list of accepted formats, see Section 14.12, “Supported qemu-img Formats”.
qemu-img convert [-c] [-p] [-f
sparse_size] filename output_filename
-pparameter shows the progress of the command (optional and not for every command) and
-Sflag allows for the creation of a sparse file, which is included within the disk image. Sparse files in all purposes function like a standard file, except that the physical blocks that only contain zeros (that is, nothing). When the Operating System sees this file, it treats it as it exists and takes up actual disk space, even though in reality it does not take any. This is particularly helpful when creating a disk for a guest virtual machine as this gives the appearance that the disk has taken much more disk space than it has. For example, if you set -S to 50Gb on a disk image that is 10Gb, then your 10Gb of disk space will appear to be 60Gb in size even though only 10Gb is actually being used.
Convert the disk image
filenameto disk image
output_format. The disk image can be optionally compressed with the
-coption, or encrypted with the
-ooption by setting
-o encryption. Note that the options available with the
-oparameter differ with the selected format.
qcow2and qcow2 format supports encryption or compression.
qcow2encryption uses the AES format with secure 128-bit keys.
qcow2compression is read-only, so if a compressed sector is converted from
qcow2format, it is written to the new format as uncompressed data.
Image conversion is also useful to get a smaller image when using a format which can grow, such as
cow. The empty sectors are detected and suppressed from the destination image.