33.3. Using qemu-img
qemu-img command line tool is used for formatting various file systems used by Xen and KVM. qemu-img should be used for formatting guest images, additional storage devices and network storage. qemu-img options and usages are listed below.
Create the new disk image filename of size size and format format.
qemu-img create [-6] [-e] [-b base_image] [-f format] filename [size]
# qemu-img create [-6] [-e] [-b base_image] [-f format] filename [size]
The convert option is used for converting a recognized format to another image format.
qemu-img convert [-c] [-e] [-f format] filename [-O output_format] output_filename
# qemu-img convert [-c] [-e] [-f format] filename [-O output_format] output_filename
filename to disk image output_filename using format output_format. The disk image can be optionally encrypted with the -e option or compressed with the -c option.
qcow" supports encryption or compression. the compression is read-only. it means that if a compressed sector is rewritten, then it is rewritten as uncompressed data.
qcow or cow. The empty sectors are detected and suppressed from the destination image.
the info parameter displays information about a disk image. the format for the info option is as follows:
qemu-img info [-f format] filename
# qemu-img info [-f format] filename
The format of an image is usually guessed automatically. The following formats are supported:
-
raw - Raw disk image format (default). This format has the advantage of being simple and easily exportable to all other emulators. If your file system supports holes (for example in ext2 or ext3 on Linux or NTFS on Windows), then only the written sectors will reserve space. Use
qemu-img infoto know the real size used by the image orls -lson Unix/Linux. -
qcow2 - QEMU image format, the most versatile format. Use it to have smaller images (useful if your file system does not supports holes, for example: on Windows), optional AES encryption, zlib based compression and support of multiple VM snapshots.
-
qcow - Old QEMU image format. Only included for compatibility with older versions.
-
cow - User Mode Linux Copy On Write image format. The
cowformat is included only for compatibility with previous versions. It does not work with Windows. -
vmdk - VMware 3 and 4 compatible image format.
-
cloop - Linux Compressed Loop image, useful only to reuse directly compressed CD-ROM images present for example in the Knoppix CD-ROMs.