.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "QEMU-IMG 1" .TH QEMU-IMG 1 "2024-11-18" " " " " .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" qemu\-img \- QEMU disk image utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBqemu-img\fR [\fIstandard\fR \fIoptions\fR] \fIcommand\fR [\fIcommand\fR \fIoptions\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" qemu-img allows you to create, convert and modify images offline. It can handle all image formats supported by \s-1QEMU.\s0 .PP \&\fBWarning:\fR Never use qemu-img to modify images in use by a running virtual machine or any other process; this may destroy the image. Also, be aware that querying an image that is being modified by another process may encounter inconsistent state. .SH "OPTIONS" .IX Header "OPTIONS" Standard options: .IP "\fB\-h, \-\-help\fR" 4 .IX Item "-h, --help" Display this help and exit .IP "\fB\-V, \-\-version\fR" 4 .IX Item "-V, --version" Display version information and exit .IP "\fB\-T, \-\-trace [[enable=]\fR\fIpattern\fR\fB][,events=\fR\fIfile\fR\fB][,file=\fR\fIfile\fR\fB]\fR" 4 .IX Item "-T, --trace [[enable=]pattern][,events=file][,file=file]" Specify tracing options. .RS 4 .IP "\fB[enable=]\fR\fIpattern\fR" 4 .IX Item "[enable=]pattern" Immediately enable events matching \fIpattern\fR. The file must contain one event name (as listed in the \fItrace-events-all\fR file) per line; globbing patterns are accepted too. This option is only available if \s-1QEMU\s0 has been compiled with the \fIsimple\fR, \fIstderr\fR or \fIftrace\fR tracing backend. To specify multiple events or patterns, specify the \fB\-trace\fR option multiple times. .Sp Use \f(CW\*(C`\-trace help\*(C'\fR to print a list of names of trace points. .IP "\fBevents=\fR\fIfile\fR" 4 .IX Item "events=file" Immediately enable events listed in \fIfile\fR. The file must contain one event name (as listed in the \fItrace-events-all\fR file) per line; globbing patterns are accepted too. This option is only available if \s-1QEMU\s0 has been compiled with the \fIsimple\fR, \fIstderr\fR or \&\fIftrace\fR tracing backend. .IP "\fBfile=\fR\fIfile\fR" 4 .IX Item "file=file" Log output traces to \fIfile\fR. This option is only available if \s-1QEMU\s0 has been compiled with the \fIsimple\fR tracing backend. .RE .RS 4 .RE .PP The following commands are supported: .IP "\fBbench [\-c\fR \fIcount\fR\fB] [\-d\fR \fIdepth\fR\fB] [\-f\fR \fIfmt\fR\fB] [\-\-flush\-interval=\fR\fIflush_interval\fR\fB] [\-n] [\-\-no\-drain] [\-o\fR \fIoffset\fR\fB] [\-\-pattern=\fR\fIpattern\fR\fB] [\-q] [\-s\fR \fIbuffer_size\fR\fB] [\-S\fR \fIstep_size\fR\fB] [\-t\fR \fIcache\fR\fB] [\-w]\fR \fIfilename\fR" 4 .IX Item "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" .PD 0 .IP "\fBcheck [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-q] [\-f\fR \fIfmt\fR\fB] [\-\-output=\fR\fIofmt\fR\fB] [\-r [leaks | all]] [\-T\fR \fIsrc_cache\fR\fB]\fR \fIfilename\fR" 4 .IX Item "check [--object objectdef] [--image-opts] [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename" .IP "\fBcreate [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-q] [\-f\fR \fIfmt\fR\fB] [\-o\fR \fIoptions\fR\fB]\fR \fIfilename\fR \fB[\fR\fIsize\fR\fB]\fR" 4 .IX Item "create [--object objectdef] [--image-opts] [-q] [-f fmt] [-o options] filename [size]" .IP "\fBcommit [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-q] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] [\-b\fR \fIbase\fR\fB] [\-d] [\-p]\fR \fIfilename\fR" 4 .IX Item "commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename" .IP "\fBcompare [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-f\fR \fIfmt\fR\fB] [\-F\fR \fIfmt\fR\fB] [\-T\fR \fIsrc_cache\fR\fB] [\-p] [\-q] [\-s]\fR \fIfilename1\fR\fB \fR\fIfilename2\fR" 4 .IX Item "compare [--object objectdef] [--image-opts] [-f fmt] [-F fmt] [-T src_cache] [-p] [-q] [-s] filename1 filename2" .IP "\fBconvert [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-c] [\-p] [\-q] [\-n] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] [\-T\fR \fIsrc_cache\fR\fB] [\-O\fR \fIoutput_fmt\fR\fB] [\-o\fR \fIoptions\fR\fB] [\-s\fR \fIsnapshot_id_or_name\fR\fB] [\-l\fR \fIsnapshot_param\fR\fB] [\-S\fR \fIsparse_size\fR\fB]\fR \fIfilename\fR \fB[\fR\fIfilename2\fR \fB[...]]\fR \fIoutput_filename\fR" 4 .IX Item "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" .IP "\fBinfo [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-f\fR \fIfmt\fR\fB] [\-\-output=\fR\fIofmt\fR\fB] [\-\-backing\-chain]\fR \fIfilename\fR" 4 .IX Item "info [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [--backing-chain] filename" .IP "\fBmap [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-f\fR \fIfmt\fR\fB] [\-\-output=\fR\fIofmt\fR\fB]\fR \fIfilename\fR" 4 .IX Item "map [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] filename" .IP "\fBsnapshot [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-q] [\-l | \-a\fR \fIsnapshot\fR \fB| \-c\fR \fIsnapshot\fR \fB| \-d\fR \fIsnapshot\fR\fB]\fR \fIfilename\fR" 4 .IX Item "snapshot [--object objectdef] [--image-opts] [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename" .IP "\fBrebase [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-q] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] [\-T\fR \fIsrc_cache\fR\fB] [\-p] [\-u] \-b\fR \fIbacking_file\fR \fB[\-F\fR \fIbacking_fmt\fR\fB]\fR \fIfilename\fR" 4 .IX Item "rebase [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename" .IP "\fBresize [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-q]\fR \fIfilename\fR \fB[+ | \-]\fR\fIsize\fR" 4 .IX Item "resize [--object objectdef] [--image-opts] [-q] filename [+ | -]size" .IP "\fBamend [\-\-object\fR \fIobjectdef\fR\fB] [\-\-image\-opts] [\-p] [\-q] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] \-o\fR \fIoptions\fR\fB \fR\fIfilename\fR" 4 .IX Item "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cache] -o options filename" .PD .PP Command parameters: .IP "\fIfilename\fR" 4 .IX Item "filename" .Vb 1 \& is a disk image filename .Ve .IP "\fI\-\-object\fR \fIobjectdef\fR" 4 .IX Item "--object objectdef" is a \s-1QEMU\s0 user creatable object definition. See the \f(CWqemu(1)\fR manual page for a description of the object properties. The most common object type is a \f(CW\*(C`secret\*(C'\fR, which is used to supply passwords and/or encryption keys. .IP "\fI\-\-image\-opts\fR" 4 .IX Item "--image-opts" Indicates that the \fIfilename\fR parameter is to be interpreted as a full option string, not a plain filename. This parameter is mutually exclusive with the \fI\-f\fR and \fI\-F\fR parameters. .IP "\fIfmt\fR" 4 .IX Item "fmt" is the disk image format. It is guessed automatically in most cases. See below for a description of the supported disk formats. .IP "\fI\-\-backing\-chain\fR" 4 .IX Item "--backing-chain" will enumerate information about backing files in a disk image chain. Refer below for further description. .IP "\fIsize\fR" 4 .IX Item "size" is the disk image size in bytes. Optional suffixes \f(CW\*(C`k\*(C'\fR or \f(CW\*(C`K\*(C'\fR (kilobyte, 1024) \f(CW\*(C`M\*(C'\fR (megabyte, 1024k) and \f(CW\*(C`G\*(C'\fR (gigabyte, 1024M) and T (terabyte, 1024G) are supported. \f(CW\*(C`b\*(C'\fR is ignored. .IP "\fIoutput_filename\fR" 4 .IX Item "output_filename" is the destination disk image filename .IP "\fIoutput_fmt\fR" 4 .IX Item "output_fmt" .Vb 1 \& is the destination format .Ve .IP "\fIoptions\fR" 4 .IX Item "options" is a comma separated list of format specific options in a name=value format. Use \f(CW\*(C`\-o ?\*(C'\fR for an overview of the options supported by the used format or see the format descriptions below for details. .IP "\fIsnapshot_param\fR" 4 .IX Item "snapshot_param" is param used for internal snapshot, format is \&'snapshot.id=[\s-1ID\s0],snapshot.name=[\s-1NAME\s0]' or '[\s-1ID_OR_NAME\s0]' .IP "\fIsnapshot_id_or_name\fR" 4 .IX Item "snapshot_id_or_name" is deprecated, use snapshot_param instead .IP "\fI\-c\fR" 4 .IX Item "-c" indicates that target image must be compressed (qcow format only) .IP "\fI\-h\fR" 4 .IX Item "-h" with or without a command shows help and lists the supported formats .IP "\fI\-p\fR" 4 .IX Item "-p" display progress bar (compare, convert and rebase commands only). If the \fI\-p\fR option is not used for a command that supports it, the progress is reported when the process receives a \f(CW\*(C`SIGUSR1\*(C'\fR signal. .IP "\fI\-q\fR" 4 .IX Item "-q" Quiet mode \- do not print any output (except errors). There's no progress bar in case both \fI\-q\fR and \fI\-p\fR options are used. .IP "\fI\-S\fR \fIsize\fR" 4 .IX Item "-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 \&\f(CW\*(C`k\*(C'\fR for kilobytes. .IP "\fI\-t\fR \fIcache\fR" 4 .IX Item "-t cache" specifies the cache mode that should be used with the (destination) file. See the documentation of the emulator's \f(CW\*(C`\-drive cache=...\*(C'\fR option for allowed values. .IP "\fI\-T\fR \fIsrc_cache\fR" 4 .IX Item "-T src_cache" specifies the cache mode that should be used with the source file(s). See the documentation of the emulator's \f(CW\*(C`\-drive cache=...\*(C'\fR option for allowed values. .PP Parameters to snapshot subcommand: .IP "\fBsnapshot\fR" 4 .IX Item "snapshot" is the name of the snapshot to create, apply or delete .IP "\fB\-a\fR" 4 .IX Item "-a" applies a snapshot (revert disk to saved state) .IP "\fB\-c\fR" 4 .IX Item "-c" creates a snapshot .IP "\fB\-d\fR" 4 .IX Item "-d" deletes a snapshot .IP "\fB\-l\fR" 4 .IX Item "-l" lists all snapshots in the given image .PP Parameters to compare subcommand: .IP "\fB\-f\fR" 4 .IX Item "-f" First image format .IP "\fB\-F\fR" 4 .IX Item "-F" Second image format .IP "\fB\-s\fR" 4 .IX Item "-s" Strict mode \- fail on different image size or sector allocation .PP Parameters to convert subcommand: .IP "\fB\-n\fR" 4 .IX Item "-n" Skip the creation of the target volume .PP Command description: .IP "\fBbench [\-c\fR \fIcount\fR\fB] [\-d\fR \fIdepth\fR\fB] [\-f\fR \fIfmt\fR\fB] [\-\-flush\-interval=\fR\fIflush_interval\fR\fB] [\-n] [\-\-no\-drain] [\-o\fR \fIoffset\fR\fB] [\-\-pattern=\fR\fIpattern\fR\fB] [\-q] [\-s\fR \fIbuffer_size\fR\fB] [\-S\fR \fIstep_size\fR\fB] [\-t\fR \fIcache\fR\fB] [\-w]\fR \fIfilename\fR" 4 .IX Item "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 \f(CW\*(C`\-w\*(C'\fR is specified, a write test is performed, otherwise a read test is performed. .Sp A total number of \fIcount\fR I/O requests is performed, each \fIbuffer_size\fR bytes in size, and with \fIdepth\fR requests in parallel. The first request starts at the position given by \fIoffset\fR, each following request increases the current position by \fIstep_size\fR. If \fIstep_size\fR is not given, \&\fIbuffer_size\fR is used for its value. .Sp If \fIflush_interval\fR is specified for a write test, the request queue is drained and a flush is issued before new writes are made whenever the number of remaining requests is a multiple of \fIflush_interval\fR. If additionally \&\f(CW\*(C`\-\-no\-drain\*(C'\fR is specified, a flush is issued without draining the request queue first. .Sp If \f(CW\*(C`\-n\*(C'\fR is specified, the native \s-1AIO\s0 backend is used if possible. On Linux, this option only works if \f(CW\*(C`\-t none\*(C'\fR or \f(CW\*(C`\-t directsync\*(C'\fR is specified as well. .Sp For write tests, by default a buffer filled with zeros is written. This can be overridden with a pattern byte specified by \fIpattern\fR. .IP "\fBcheck [\-f\fR \fIfmt\fR\fB] [\-\-output=\fR\fIofmt\fR\fB] [\-r [leaks | all]] [\-T\fR \fIsrc_cache\fR\fB]\fR \fIfilename\fR" 4 .IX Item "check [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] filename" Perform a consistency check on the disk image \fIfilename\fR. The command can output in the format \fIofmt\fR which is either \f(CW\*(C`human\*(C'\fR or \f(CW\*(C`json\*(C'\fR. .Sp If \f(CW\*(C`\-r\*(C'\fR is specified, qemu-img tries to repair any inconsistencies found during the check. \f(CW\*(C`\-r leaks\*(C'\fR repairs only cluster leaks, whereas \&\f(CW\*(C`\-r all\*(C'\fR fixes all kinds of errors, with a higher risk of choosing the wrong fix or hiding corruption that has already occurred. .Sp Only the formats \f(CW\*(C`qcow2\*(C'\fR, \f(CW\*(C`qed\*(C'\fR and \f(CW\*(C`vdi\*(C'\fR support consistency checks. .Sp In case the image does not have any inconsistencies, check exits with \f(CW0\fR. Other exit codes indicate the kind of inconsistency found or if another error occurred. The following table summarizes all exit codes of the check subcommand: .RS 4 .IP "\fB0\fR" 4 .IX Item "0" Check completed, the image is (now) consistent .IP "\fB1\fR" 4 .IX Item "1" Check not completed because of internal errors .IP "\fB2\fR" 4 .IX Item "2" Check completed, image is corrupted .IP "\fB3\fR" 4 .IX Item "3" Check completed, image has leaked clusters, but is not corrupted .IP "\fB63\fR" 4 .IX Item "63" Checks are not supported by the image format .RE .RS 4 .Sp If \f(CW\*(C`\-r\*(C'\fR is specified, exit codes representing the image state refer to the state after (the attempt at) repairing it. That is, a successful \f(CW\*(C`\-r all\*(C'\fR will yield the exit code 0, independently of the image state before. .RE .IP "\fBcreate [\-f\fR \fIfmt\fR\fB] [\-o\fR \fIoptions\fR\fB]\fR \fIfilename\fR \fB[\fR\fIsize\fR\fB]\fR" 4 .IX Item "create [-f fmt] [-o options] filename [size]" Create the new disk image \fIfilename\fR of size \fIsize\fR and format \&\fIfmt\fR. Depending on the file format, you can add one or more \fIoptions\fR that enable additional features of this format. .Sp If the option \fIbacking_file\fR is specified, then the image will record only the differences from \fIbacking_file\fR. No size needs to be specified in this case. \fIbacking_file\fR will never be modified unless you use the \&\f(CW\*(C`commit\*(C'\fR monitor command (or qemu-img commit). .Sp The size can also be specified using the \fIsize\fR option with \f(CW\*(C`\-o\*(C'\fR, it doesn't need to be specified separately in this case. .IP "\fBcommit [\-q] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] [\-b\fR \fIbase\fR\fB] [\-d] [\-p]\fR \fIfilename\fR" 4 .IX Item "commit [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename" Commit the changes recorded in \fIfilename\fR 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. .Sp The image \fIfilename\fR is emptied after the operation has succeeded. If you do not need \fIfilename\fR afterwards and intend to drop it, you may skip emptying \&\fIfilename\fR by specifying the \f(CW\*(C`\-d\*(C'\fR flag. .Sp If the backing chain of the given image file \fIfilename\fR has more than one layer, the backing file into which the changes will be committed may be specified as \fIbase\fR (which has to be part of \fIfilename\fR's backing chain). If \fIbase\fR is not specified, the immediate backing file of the top image (which is \fIfilename\fR) will be used. For reasons of consistency, explicitly specifying \fIbase\fR will always imply \f(CW\*(C`\-d\*(C'\fR (since emptying an image after committing to an indirect backing file would lead to different data being read from the image due to content in the intermediate backing chain overruling the commit target). .IP "\fBcompare [\-f\fR \fIfmt\fR\fB] [\-F\fR \fIfmt\fR\fB] [\-T\fR \fIsrc_cache\fR\fB] [\-p] [\-s] [\-q]\fR \fIfilename1\fR\fB \fR\fIfilename2\fR" 4 .IX Item "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. .Sp The format is probed unless you specify it by \fI\-f\fR (used for \&\fIfilename1\fR) and/or \fI\-F\fR (used for \fIfilename2\fR) option. .Sp By default, images with different size are considered identical if the larger image contains only unallocated and/or zeroed sectors in the area after the end of the other image. In addition, if any sector is not allocated in one image and contains only zero bytes in the second one, it is evaluated as equal. You can use Strict mode by specifying the \fI\-s\fR option. When compare runs in Strict mode, it fails in case image size differs or a sector is allocated in one image and is not allocated in the second one. .Sp By default, compare prints out a result message. This message displays information that both images are same or the position of the first different byte. In addition, result message can report different image size in case Strict mode is used. .Sp Compare exits with \f(CW0\fR in case the images are equal and with \f(CW1\fR in case the images differ. Other exit codes mean an error occurred during execution and standard error output should contain an error message. The following table sumarizes all exit codes of the compare subcommand: .RS 4 .IP "\fB0\fR" 4 .IX Item "0" Images are identical .IP "\fB1\fR" 4 .IX Item "1" Images differ .IP "\fB2\fR" 4 .IX Item "2" Error on opening an image .IP "\fB3\fR" 4 .IX Item "3" Error on checking a sector allocation .IP "\fB4\fR" 4 .IX Item "4" Error on reading data .RE .RS 4 .RE .IP "\fBconvert [\-c] [\-p] [\-n] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] [\-T\fR \fIsrc_cache\fR\fB] [\-O\fR \fIoutput_fmt\fR\fB] [\-o\fR \fIoptions\fR\fB] [\-s\fR \fIsnapshot_id_or_name\fR\fB] [\-l\fR \fIsnapshot_param\fR\fB] [\-S\fR \fIsparse_size\fR\fB]\fR \fIfilename\fR \fB[\fR\fIfilename2\fR \fB[...]]\fR \fIoutput_filename\fR" 4 .IX Item "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 \fIfilename\fR or a snapshot \fIsnapshot_param\fR(\fIsnapshot_id_or_name\fR is deprecated) to disk image \fIoutput_filename\fR using format \fIoutput_fmt\fR. It can be optionally compressed (\f(CW\*(C`\-c\*(C'\fR option) or use any format specific options like encryption (\f(CW\*(C`\-o\*(C'\fR option). .Sp Only the formats \f(CW\*(C`qcow\*(C'\fR and \f(CW\*(C`qcow2\*(C'\fR support compression. The compression is read-only. It means that if a compressed sector is rewritten, then it is rewritten as uncompressed data. .Sp Image conversion is also useful to get smaller image when using a growable format such as \f(CW\*(C`qcow\*(C'\fR: the empty sectors are detected and suppressed from the destination image. .Sp \&\fIsparse_size\fR indicates the consecutive number of bytes (defaults to 4k) that must contain only zeros for qemu-img to create a sparse image during conversion. If \fIsparse_size\fR is 0, the source will not be scanned for unallocated or zero sectors, and the destination image will always be fully allocated. .Sp You can use the \fIbacking_file\fR option to force the output image to be created as a copy on write image of the specified base image; the \&\fIbacking_file\fR should have the same content as the input's base image, however the path, image format, etc may differ. .Sp If the \f(CW\*(C`\-n\*(C'\fR option is specified, the target volume creation will be skipped. This is useful for formats such as \f(CW\*(C`rbd\*(C'\fR if the target volume has already been created with site specific options that cannot be supplied through qemu-img. .IP "\fBinfo [\-f\fR \fIfmt\fR\fB] [\-\-output=\fR\fIofmt\fR\fB] [\-\-backing\-chain]\fR \fIfilename\fR" 4 .IX Item "info [-f fmt] [--output=ofmt] [--backing-chain] filename" Give information about the disk image \fIfilename\fR. Use it in particular to know the size reserved on disk which can be different from the displayed size. If \s-1VM\s0 snapshots are stored in the disk image, they are displayed too. The command can output in the format \fIofmt\fR which is either \f(CW\*(C`human\*(C'\fR or \f(CW\*(C`json\*(C'\fR. .Sp If a disk image has a backing file chain, information about each disk image in the chain can be recursively enumerated by using the option \f(CW\*(C`\-\-backing\-chain\*(C'\fR. .Sp For instance, if you have an image chain like: .Sp .Vb 1 \& base.qcow2 <\- snap1.qcow2 <\- snap2.qcow2 .Ve .Sp To enumerate information about each disk image in the above chain, starting from top to base, do: .Sp .Vb 1 \& qemu\-img info \-\-backing\-chain snap2.qcow2 .Ve .IP "\fBmap [\-f\fR \fIfmt\fR\fB] [\-\-output=\fR\fIofmt\fR\fB]\fR \fIfilename\fR" 4 .IX Item "map [-f fmt] [--output=ofmt] filename" Dump the metadata of image \fIfilename\fR and its backing file chain. In particular, this commands dumps the allocation state of every sector of \fIfilename\fR, together with the topmost file that allocates it in the backing file chain. .Sp Two option formats are possible. The default format (\f(CW\*(C`human\*(C'\fR) only dumps known-nonzero areas of the file. Known-zero parts of the file are omitted altogether, and likewise for parts that are not allocated throughout the chain. \fBqemu-img\fR output will identify a file from where the data can be read, and the offset in the file. Each line will include four fields, the first three of which are hexadecimal numbers. For example the first line of: .Sp .Vb 3 \& Offset Length Mapped to File \& 0 0x20000 0x50000 /tmp/overlay.qcow2 \& 0x100000 0x10000 0x95380000 /tmp/backing.qcow2 .Ve .Sp means that 0x20000 (131072) bytes starting at offset 0 in the image are available in /tmp/overlay.qcow2 (opened in \f(CW\*(C`raw\*(C'\fR format) starting at offset 0x50000 (327680). Data that is compressed, encrypted, or otherwise not available in raw format will cause an error if \f(CW\*(C`human\*(C'\fR format is in use. Note that file names can include newlines, thus it is not safe to parse this output format in scripts. .Sp The alternative format \f(CW\*(C`json\*(C'\fR will return an array of dictionaries in \s-1JSON\s0 format. It will include similar information in the \f(CW\*(C`start\*(C'\fR, \f(CW\*(C`length\*(C'\fR, \f(CW\*(C`offset\*(C'\fR fields; it will also include other more specific information: .RS 4 .IP "\-" 4 whether the sectors contain actual data or not (boolean field \f(CW\*(C`data\*(C'\fR; if false, the sectors are either unallocated or stored as optimized all-zero clusters); .IP "\-" 4 whether the data is known to read as zero (boolean field \f(CW\*(C`zero\*(C'\fR); .IP "\-" 4 in order to make the output shorter, the target file is expressed as a \f(CW\*(C`depth\*(C'\fR; for example, a depth of 2 refers to the backing file of the backing file of \fIfilename\fR. .RE .RS 4 .Sp In \s-1JSON\s0 format, the \f(CW\*(C`offset\*(C'\fR field is optional; it is absent in cases where \f(CW\*(C`human\*(C'\fR format would omit the entry or exit with an error. If \f(CW\*(C`data\*(C'\fR is false and the \f(CW\*(C`offset\*(C'\fR field is present, the corresponding sectors in the file are not yet in use, but they are preallocated. .Sp For more information, consult \fIinclude/block/block.h\fR in \s-1QEMU\s0's source code. .RE .IP "\fBsnapshot [\-l | \-a\fR \fIsnapshot\fR \fB| \-c\fR \fIsnapshot\fR \fB| \-d\fR \fIsnapshot\fR \fB]\fR \fIfilename\fR" 4 .IX Item "snapshot [-l | -a snapshot | -c snapshot | -d snapshot ] filename" List, apply, create or delete snapshots in image \fIfilename\fR. .IP "\fBrebase [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] [\-T\fR \fIsrc_cache\fR\fB] [\-p] [\-u] \-b\fR \fIbacking_file\fR \fB[\-F\fR \fIbacking_fmt\fR\fB]\fR \fIfilename\fR" 4 .IX Item "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 \f(CW\*(C`qcow2\*(C'\fR and \&\f(CW\*(C`qed\*(C'\fR support changing the backing file. .Sp The backing file is changed to \fIbacking_file\fR and (if the image format of \&\fIfilename\fR supports this) the backing file format is changed to \&\fIbacking_fmt\fR. If \fIbacking_file\fR is specified as "" (the empty string), then the image is rebased onto no backing file (i.e. it will exist independently of any backing file). .Sp \&\fIcache\fR specifies the cache mode to be used for \fIfilename\fR, whereas \&\fIsrc_cache\fR specifies the cache mode for reading backing files. .Sp There are two different modes in which \f(CW\*(C`rebase\*(C'\fR can operate: .RS 4 .IP "\fBSafe mode\fR" 4 .IX Item "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 \fIfilename\fR unchanged. .Sp In order to achieve this, any clusters that differ between \fIbacking_file\fR and the old backing file of \fIfilename\fR are merged into \fIfilename\fR before actually changing the backing file. .Sp Note that the safe mode is an expensive operation, comparable to converting an image. It only works if the old backing file still exists. .IP "\fBUnsafe mode\fR" 4 .IX Item "Unsafe mode" qemu-img uses the unsafe mode if \f(CW\*(C`\-u\*(C'\fR is specified. In this mode, only the backing file name and format of \fIfilename\fR 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. .Sp This mode is useful for renaming or moving the backing file to somewhere else. It can be used without an accessible old backing file, i.e. you can use it to fix an image whose backing file has already been moved/renamed. .RE .RS 4 .Sp You can use \f(CW\*(C`rebase\*(C'\fR to perform a \*(L"diff\*(R" operation on two disk images. This can be useful when you have copied or cloned a guest, and you want to get back to a thin image on top of a template or base image. .Sp Say that \f(CW\*(C`base.img\*(C'\fR has been cloned as \f(CW\*(C`modified.img\*(C'\fR by copying it, and that the \f(CW\*(C`modified.img\*(C'\fR guest has run so there are now some changes compared to \f(CW\*(C`base.img\*(C'\fR. To construct a thin image called \f(CW\*(C`diff.qcow2\*(C'\fR that contains just the differences, do: .Sp .Vb 2 \& qemu\-img create \-f qcow2 \-b modified.img diff.qcow2 \& qemu\-img rebase \-b base.img diff.qcow2 .Ve .Sp At this point, \f(CW\*(C`modified.img\*(C'\fR can be discarded, since \&\f(CW\*(C`base.img + diff.qcow2\*(C'\fR contains the same information. .RE .IP "\fBresize\fR \fIfilename\fR \fB[+ | \-]\fR\fIsize\fR" 4 .IX Item "resize filename [+ | -]size" Change the disk image as if it had been created with \fIsize\fR. .Sp Before using this command to shrink a disk image, you \s-1MUST\s0 use file system and partitioning tools inside the \s-1VM\s0 to reduce allocated file systems and partition sizes accordingly. Failure to do so will result in data loss! .Sp After using this command to grow a disk image, you must use file system and partitioning tools inside the \s-1VM\s0 to actually begin using the new space on the device. .IP "\fBamend [\-p] [\-f\fR \fIfmt\fR\fB] [\-t\fR \fIcache\fR\fB] \-o\fR \fIoptions\fR\fB \fR\fIfilename\fR" 4 .IX Item "amend [-p] [-f fmt] [-t cache] -o options filename" Amends the image format specific \fIoptions\fR for the image file \&\fIfilename\fR. Not all file formats support this operation. .SH "NOTES" .IX Header "NOTES" Supported image file formats: .IP "\fBraw\fR" 4 .IX Item "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 \fIholes\fR (for example in ext2 or ext3 on Linux or \s-1NTFS\s0 on Windows), then only the written sectors will reserve space. Use \f(CW\*(C`qemu\-img info\*(C'\fR to know the real size used by the image or \f(CW\*(C`ls \-ls\*(C'\fR on Unix/Linux. .Sp Supported options: .RS 4 .ie n .IP """preallocation""" 4 .el .IP "\f(CWpreallocation\fR" 4 .IX Item "preallocation" Preallocation mode (allowed values: \f(CW\*(C`off\*(C'\fR, \f(CW\*(C`falloc\*(C'\fR, \f(CW\*(C`full\*(C'\fR). \&\f(CW\*(C`falloc\*(C'\fR mode preallocates space for image by calling \fBposix_fallocate()\fR. \&\f(CW\*(C`full\*(C'\fR mode preallocates space for image by writing zeros to underlying storage. .RE .RS 4 .RE .IP "\fBqcow2\fR" 4 .IX Item "qcow2" \&\s-1QEMU\s0 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 \s-1AES\s0 encryption, zlib based compression and support of multiple \s-1VM\s0 snapshots. .Sp Supported options: .RS 4 .ie n .IP """compat""" 4 .el .IP "\f(CWcompat\fR" 4 .IX Item "compat" Determines the qcow2 version to use. \f(CW\*(C`compat=0.10\*(C'\fR uses the traditional image format that can be read by any \s-1QEMU\s0 since 0.10. \&\f(CW\*(C`compat=1.1\*(C'\fR enables image format extensions that only \s-1QEMU 1.1\s0 and newer understand (this is the default). Amongst others, this includes zero clusters, which allow efficient copy-on-read for sparse images. .ie n .IP """backing_file""" 4 .el .IP "\f(CWbacking_file\fR" 4 .IX Item "backing_file" File name of a base image (see \fBcreate\fR subcommand) .ie n .IP """backing_fmt""" 4 .el .IP "\f(CWbacking_fmt\fR" 4 .IX Item "backing_fmt" Image format of the base image .ie n .IP """encryption""" 4 .el .IP "\f(CWencryption\fR" 4 .IX Item "encryption" If this option is set to \f(CW\*(C`on\*(C'\fR, the image is encrypted with 128\-bit AES-CBC. .Sp The use of encryption in qcow and qcow2 images is considered to be flawed by modern cryptography standards, suffering from a number of design problems: .RS 4 .IP "\-" 4 .IX Item "-" on the sector number. This makes it vulnerable to chosen plaintext attacks which can reveal the existence of encrypted data. .IP "\-" 4 .IX Item "-" chosen or short passphrase will compromise the security of the encryption. .IP "\-" 4 .IX Item "-" 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. .RE .RS 4 .Sp Use of qcow / qcow2 encryption is thus strongly discouraged. Users are recommended to use an alternative encryption technology such as the Linux dm-crypt / \s-1LUKS\s0 system. .RE .ie n .IP """cluster_size""" 4 .el .IP "\f(CWcluster_size\fR" 4 .IX Item "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. .ie n .IP """preallocation""" 4 .el .IP "\f(CWpreallocation\fR" 4 .IX Item "preallocation" Preallocation mode (allowed values: \f(CW\*(C`off\*(C'\fR, \f(CW\*(C`metadata\*(C'\fR, \f(CW\*(C`falloc\*(C'\fR, \&\f(CW\*(C`full\*(C'\fR). An image with preallocated metadata is initially larger but can improve performance when the image needs to grow. \f(CW\*(C`falloc\*(C'\fR and \f(CW\*(C`full\*(C'\fR preallocations are like the same options of \f(CW\*(C`raw\*(C'\fR format, but sets up metadata also. .ie n .IP """lazy_refcounts""" 4 .el .IP "\f(CWlazy_refcounts\fR" 4 .IX Item "lazy_refcounts" If this option is set to \f(CW\*(C`on\*(C'\fR, reference count updates are postponed with the goal of avoiding metadata I/O and improving performance. This is particularly interesting with \fBcache=writethrough\fR 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) \f(CW\*(C`qemu\-img check \-r all\*(C'\fR is required, which may take some time. .Sp This option can only be enabled if \f(CW\*(C`compat=1.1\*(C'\fR is specified. .ie n .IP """nocow""" 4 .el .IP "\f(CWnocow\fR" 4 .IX Item "nocow" If this option is set to \f(CW\*(C`on\*(C'\fR, it will turn off \s-1COW\s0 of the file. It's only valid on btrfs, no effect on other file systems. .Sp Btrfs has low performance when hosting a \s-1VM\s0 image file, even more when the guest on the \s-1VM\s0 also using btrfs as file system. Turning off \s-1COW\s0 is a way to mitigate this bad performance. Generally there are two ways to turn off \s-1COW\s0 on btrfs: a) Disable it by mounting with nodatacow, then all newly created files will be \&\s-1NOCOW.\s0 b) For an empty file, add the \s-1NOCOW\s0 file attribute. That's what this option does. .Sp Note: this option is only valid to new or empty files. If there is an existing file which is \s-1COW\s0 and has data blocks already, it couldn't be changed to \s-1NOCOW\s0 by setting \f(CW\*(C`nocow=on\*(C'\fR. One can issue \f(CW\*(C`lsattr filename\*(C'\fR to check if the \s-1NOCOW\s0 flag is set or not (Capital 'C' is \s-1NOCOW\s0 flag). .RE .RS 4 .RE .IP "\fBOther\fR" 4 .IX Item "Other" \&\s-1QEMU\s0 also supports various other image file formats for compatibility with older \s-1QEMU\s0 versions or other hypervisors, including \s-1VMDK, VDI, VHD\s0 (vpc), \s-1VHDX,\s0 qcow1 and \s-1QED.\s0 For a full list of supported formats see \f(CW\*(C`qemu\-img \-\-help\*(C'\fR. For a more detailed description of these formats, see the \s-1QEMU\s0 Emulation User Documentation. .Sp The main purpose of the block drivers for these formats is image conversion. For running VMs, it is recommended to convert the disk images to either raw or qcow2 in order to achieve good performance. .SH "SEE ALSO" .IX Header "SEE ALSO" The \s-1HTML\s0 documentation of \s-1QEMU\s0 for more precise information and Linux user mode emulator invocation. .SH "AUTHOR" .IX Header "AUTHOR" Fabrice Bellard