Sortix nightly manual
This manual documents Sortix nightly, a development build that has not been officially released. You can instead view this document in the latest official manual.
QEMU-IMG(1) | QEMU-IMG(1) |
NAME
qemu-img - QEMU disk image utilitySYNOPSIS
qemu-img [standard options] command [command options]DESCRIPTION
qemu-img allows you to create, convert and modify images offline. It can handle all image formats supported by QEMU.OPTIONS
Standard options:- -h, --help
- Display this help and exit
- -V, --version
- Display version information and exit
- -T, --trace [[enable=]pattern][,events=file][,file=file]
- Specify tracing options.
- [enable=]pattern
-
Immediately enable events matching pattern. The file must contain one event name (as listed in the trace-events-all file) per line; globbing patterns are accepted too. This option is only available if QEMU has been compiled with the simple, stderr or ftrace tracing backend. To specify multiple events or patterns, specify the -trace option multiple times.
- events=file
- Immediately enable events listed in file. The file must contain one event name (as listed in the trace-events-all file) per line; globbing patterns are accepted too. This option is only available if QEMU has been compiled with the simple, stderr or ftrace tracing backend.
- file=file
- Log output traces to file. This option is only available if QEMU has been compiled with the simple tracing backend.
- bench [-c count] [-d depth] [-f fmt] [--flush-interval=flush_interval] [-n] [--no-drain] [-o offset] [--pattern=pattern] [-q] [-s buffer_size] [-S step_size] [-t cache] [-w] filename
- check [--object objectdef] [--image-opts] [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename
- create [--object objectdef] [--image-opts] [-q] [-f fmt] [-o options] filename [size]
- commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename
- compare [--object objectdef] [--image-opts] [-f fmt] [-F fmt] [-T src_cache] [-p] [-q] [-s] filename1 filename2
- convert [--object objectdef] [--image-opts] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] filename [filename2 [...]] output_filename
- info [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [--backing-chain] filename
- map [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] filename
- snapshot [--object objectdef] [--image-opts] [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename
- rebase [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename
- resize [--object objectdef] [--image-opts] [-q] filename [+ | -]size
- amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cache] -o options filename
- filename
-
is a disk image filename
- --object objectdef
- is a QEMU user creatable object definition. See the qemu(1) manual page for a description of the object properties. The most common object type is a "secret", which is used to supply passwords and/or encryption keys.
- --image-opts
- Indicates that the filename parameter is to be interpreted as a full option string, not a plain filename. This parameter is mutually exclusive with the -f and -F parameters.
- fmt
- is the disk image format. It is guessed automatically in most cases. See below for a description of the supported disk formats.
- --backing-chain
- will enumerate information about backing files in a disk image chain. Refer below for further description.
- size
- is the disk image size in bytes. Optional suffixes "k" or "K" (kilobyte, 1024) "M" (megabyte, 1024k) and "G" (gigabyte, 1024M) and T (terabyte, 1024G) are supported. "b" is ignored.
- output_filename
- is the destination disk image filename
- output_fmt
-
is the destination format
- options
- is a comma separated list of format specific options in a name=value format. Use "-o ?" for an overview of the options supported by the used format or see the format descriptions below for details.
- snapshot_param
- is param used for internal snapshot, format is 'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
- snapshot_id_or_name
- is deprecated, use snapshot_param instead
- -c
- indicates that target image must be compressed (qcow format only)
- -h
- with or without a command shows help and lists the supported formats
- -p
- display progress bar (compare, convert and rebase commands only). If the -p option is not used for a command that supports it, the progress is reported when the process receives a "SIGUSR1" signal.
- -q
- Quiet mode - do not print any output (except errors). There's no progress bar in case both -q and -p options are used.
- -S size
- indicates the consecutive number of bytes that must contain only zeros for qemu-img to create a sparse image during conversion. This value is rounded down to the nearest 512 bytes. You may use the common size suffixes like "k" for kilobytes.
- -t cache
- specifies the cache mode that should be used with the (destination) file. See the documentation of the emulator's "-drive cache=..." option for allowed values.
- -T src_cache
- specifies the cache mode that should be used with the source file(s). See the documentation of the emulator's "-drive cache=..." option for allowed values.
- snapshot
- is the name of the snapshot to create, apply or delete
- -a
- applies a snapshot (revert disk to saved state)
- -c
- creates a snapshot
- -d
- deletes a snapshot
- -l
- lists all snapshots in the given image
- -f
- First image format
- -F
- Second image format
- -s
- Strict mode - fail on different image size or sector allocation
- -n
- Skip the creation of the target volume
- bench [-c count] [-d depth] [-f fmt] [--flush-interval=flush_interval] [-n] [--no-drain] [-o offset] [--pattern=pattern] [-q] [-s buffer_size] [-S step_size] [-t cache] [-w] filename
-
Run a simple sequential I/O benchmark on the specified image. If "-w" is specified, a write test is performed, otherwise a read test is performed.
- check [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename
-
Perform a consistency check on the disk image filename. The command can output in the format ofmt which is either "human" or "json".
- 0
- Check completed, the image is (now) consistent
- 1
- Check not completed because of internal errors
- 2
- Check completed, image is corrupted
- 3
- Check completed, image has leaked clusters, but is not corrupted
- 63
- Checks are not supported by the image format
- create [-f fmt] [-o options] filename [size]
-
Create the new disk image filename of size size and format fmt. Depending on the file format, you can add one or more options that enable additional features of this format.
- commit [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename
-
Commit the changes recorded in filename in its base image or backing file. If the backing file is smaller than the snapshot, then the backing file will be resized to be the same size as the snapshot. If the snapshot is smaller than the backing file, the backing file will not be truncated. If you want the backing file to match the size of the smaller snapshot, you can safely truncate it yourself once the commit operation successfully completes.
- compare [-f fmt] [-F fmt] [-T src_cache] [-p] [-s] [-q] filename1 filename2
-
Check if two images have the same content. You can compare images with different format or settings.
- 0
- Images are identical
- 1
- Images differ
- 2
- Error on opening an image
- 3
- Error on checking a sector allocation
- 4
- Error on reading data
- convert [-c] [-p] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] filename [filename2 [...]] output_filename
-
Convert the disk image filename or a snapshot snapshot_param(snapshot_id_or_name is deprecated) to disk image output_filename using format output_fmt. It can be optionally compressed ("-c" option) or use any format specific options like encryption ("-o" option).
- info [-f fmt] [--output=ofmt] [--backing-chain] filename
-
Give information about the disk image filename. Use it in particular to know the size reserved on disk which can be different from the displayed size. If VM snapshots are stored in the disk image, they are displayed too. The command can output in the format ofmt which is either "human" or "json".
base.qcow2 <- snap1.qcow2 <- snap2.qcow2
qemu-img info --backing-chain snap2.qcow2
- map [-f fmt] [--output=ofmt] filename
-
Dump the metadata of image filename and its backing file chain. In particular, this commands dumps the allocation state of every sector of filename, together with the topmost file that allocates it in the backing file chain.
Offset Length Mapped to File
0 0x20000 0x50000 /tmp/overlay.qcow2
0x100000 0x10000 0x95380000 /tmp/backing.qcow2
- -
- whether the sectors contain actual data or not (boolean field "data"; if false, the sectors are either unallocated or stored as optimized all-zero clusters);
- -
- whether the data is known to read as zero (boolean field "zero");
- -
- in order to make the output shorter, the target file is expressed as a "depth"; for example, a depth of 2 refers to the backing file of the backing file of filename.
- snapshot [-l | -a snapshot | -c snapshot | -d snapshot ] filename
- List, apply, create or delete snapshots in image filename.
- rebase [-f fmt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename
-
Changes the backing file of an image. Only the formats "qcow2" and "qed" support changing the backing file.
- Safe mode
-
This is the default mode and performs a real rebase operation. The new backing file may differ from the old one and qemu-img rebase will take care of keeping the guest-visible content of filename unchanged.
- Unsafe mode
-
qemu-img uses the unsafe mode if "-u" is specified. In this mode, only the backing file name and format of filename is changed without any checks on the file contents. The user must take care of specifying the correct new backing file, or the guest-visible content of the image will be corrupted.
qemu-img create -f qcow2 -b modified.img diff.qcow2
qemu-img rebase -b base.img diff.qcow2
- resize filename [+ | -]size
-
Change the disk image as if it had been created with size.
- amend [-p] [-f fmt] [-t cache] -o options filename
- Amends the image format specific options for the image file filename. Not all file formats support this operation.
NOTES
Supported image file formats:- 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 info" to know the real size used by the image or "ls -ls" on Unix/Linux.
- "preallocation"
- Preallocation mode (allowed values: "off", "falloc", "full"). "falloc" mode preallocates space for image by calling posix_fallocate(). "full" mode preallocates space for image by writing zeros to underlying storage.
- qcow2
-
QEMU image format, the most versatile format. Use it to have smaller images (useful if your filesystem does not supports holes, for example on Windows), optional AES encryption, zlib based compression and support of multiple VM snapshots.
- "compat"
- Determines the qcow2 version to use. "compat=0.10" uses the traditional image format that can be read by any QEMU since 0.10. "compat=1.1" enables image format extensions that only QEMU 1.1 and newer understand (this is the default). Amongst others, this includes zero clusters, which allow efficient copy-on-read for sparse images.
- "backing_file"
- File name of a base image (see create subcommand)
- "backing_fmt"
- Image format of the base image
- "encryption"
-
If this option is set to "on", the image is encrypted with 128-bit AES-CBC.
- -<The AES-CBC cipher is used with predictable initialization vectors based>
- on the sector number. This makes it vulnerable to chosen plaintext attacks which can reveal the existence of encrypted data.
- -<The user passphrase is directly used as the encryption key. A poorly>
- chosen or short passphrase will compromise the security of the encryption.
- -<In the event of the passphrase being compromised there is no way to>
- change the passphrase to protect data in any qcow images. The files must be cloned, using a different encryption passphrase in the new file. The original file must then be securely erased using a program like shred, though even this is ineffective with many modern storage technologies.
- "cluster_size"
- Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster sizes can improve the image file size whereas larger cluster sizes generally provide better performance.
- "preallocation"
- Preallocation mode (allowed values: "off", "metadata", "falloc", "full"). An image with preallocated metadata is initially larger but can improve performance when the image needs to grow. "falloc" and "full" preallocations are like the same options of "raw" format, but sets up metadata also.
- "lazy_refcounts"
-
If this option is set to "on", reference count updates are postponed with the goal of avoiding metadata I/O and improving performance. This is particularly interesting with cache=writethrough which doesn't batch metadata updates. The tradeoff is that after a host crash, the reference count tables must be rebuilt, i.e. on the next open an (automatic) "qemu-img check -r all" is required, which may take some time.
- "nocow"
-
If this option is set to "on", it will turn off COW of the file. It's only valid on btrfs, no effect on other file systems.
- Other
-
QEMU also supports various other image file formats for compatibility with older QEMU versions or other hypervisors, including VMDK, VDI, VHD (vpc), VHDX, qcow1 and QED. For a full list of supported formats see "qemu-img --help". For a more detailed description of these formats, see the QEMU Emulation User Documentation.
SEE ALSO
The HTML documentation of QEMU for more precise information and Linux user mode emulator invocation.AUTHOR
Fabrice Bellard2024-12-21 |