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
# qemu-img create [-6] [-e] [-b base_image] [-f format] filename [size]
convert option is used for converting a recognized format to another image format.
# qemu-img convert [-c] [-e] [-f format]
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
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.
cow. The empty sectors are detected and suppressed from the destination image.
info parameter displays information about a disk image. the format for the
info option is as follows:
# qemu-img info [-f format] filename
The format of an image is usually guessed automatically. The following formats are supported:
- 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 or
ls -lson Unix/Linux.
- 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.
- Old QEMU image format. Only included for compatibility with older versions.
- User Mode Linux Copy On Write image format. The
cowformat is included only for compatibility with previous versions. It does not work with Windows.
- VMware 3 and 4 compatible image format.
- Linux Compressed Loop image, useful only to reuse directly compressed CD-ROM images present for example in the Knoppix CD-ROMs.