Statistics
| Branch: | Revision:

root / qemu-img.texi @ c48c6522

History | View | Annotate | Download (11.1 kB)

1 acd935ef bellard
@example
2 acd935ef bellard
@c man begin SYNOPSIS
3 acd935ef bellard
usage: qemu-img command [command options]
4 acd935ef bellard
@c man end
5 acd935ef bellard
@end example
6 acd935ef bellard
7 acd935ef bellard
@c man begin OPTIONS
8 acd935ef bellard
9 acd935ef bellard
The following commands are supported:
10 153859be Stuart Brady
11 153859be Stuart Brady
@include qemu-img-cmds.texi
12 acd935ef bellard
13 acd935ef bellard
Command parameters:
14 acd935ef bellard
@table @var
15 acd935ef bellard
@item filename
16 acd935ef bellard
 is a disk image filename
17 5fafdf24 ths
@item fmt
18 f932c040 Kevin Wolf
is the disk image format. It is guessed automatically in most cases. See below
19 f932c040 Kevin Wolf
for a description of the supported disk formats.
20 acd935ef bellard
21 5fafdf24 ths
@item size
22 eff44266 Kevin Wolf
is the disk image size in bytes. Optional suffixes @code{k} or @code{K}
23 eff44266 Kevin Wolf
(kilobyte, 1024) @code{M} (megabyte, 1024k) and @code{G} (gigabyte, 1024M)
24 eff44266 Kevin Wolf
and T (terabyte, 1024G) are supported.  @code{b} is ignored.
25 acd935ef bellard
26 acd935ef bellard
@item output_filename
27 5fafdf24 ths
is the destination disk image filename
28 acd935ef bellard
29 acd935ef bellard
@item output_fmt
30 acd935ef bellard
 is the destination format
31 eff44266 Kevin Wolf
@item options
32 eff44266 Kevin Wolf
is a comma separated list of format specific options in a
33 eff44266 Kevin Wolf
name=value format. Use @code{-o ?} for an overview of the options supported
34 3e032364 Kevin Wolf
by the used format or see the format descriptions below for details.
35 eff44266 Kevin Wolf
36 acd935ef bellard
37 acd935ef bellard
@item -c
38 acd935ef bellard
indicates that target image must be compressed (qcow format only)
39 d2c639d6 blueswir1
@item -h
40 d2c639d6 blueswir1
with or without a command shows help and lists the supported formats
41 aaf55b47 Jes Sorensen
@item -p
42 aaf55b47 Jes Sorensen
display progress bar (convert and rebase commands only)
43 a22f123c Kevin Wolf
@item -S @var{size}
44 a22f123c Kevin Wolf
indicates the consecutive number of bytes that must contain only zeros
45 a22f123c Kevin Wolf
for qemu-img to create a sparse image during conversion. This value is rounded
46 a22f123c Kevin Wolf
down to the nearest 512 bytes. You may use the common size suffixes like
47 a22f123c Kevin Wolf
@code{k} for kilobytes.
48 3763f26f Kevin Wolf
@item -t @var{cache}
49 3763f26f Kevin Wolf
specifies the cache mode that should be used with the (destination) file. See
50 3763f26f Kevin Wolf
the documentation of the emulator's @code{-drive cache=...} option for allowed
51 3763f26f Kevin Wolf
values.
52 d2c639d6 blueswir1
@end table
53 d2c639d6 blueswir1
54 d2c639d6 blueswir1
Parameters to snapshot subcommand:
55 d2c639d6 blueswir1
56 d2c639d6 blueswir1
@table @option
57 d2c639d6 blueswir1
58 d2c639d6 blueswir1
@item snapshot
59 d2c639d6 blueswir1
is the name of the snapshot to create, apply or delete
60 d2c639d6 blueswir1
@item -a
61 d2c639d6 blueswir1
applies a snapshot (revert disk to saved state)
62 d2c639d6 blueswir1
@item -c
63 d2c639d6 blueswir1
creates a snapshot
64 d2c639d6 blueswir1
@item -d
65 d2c639d6 blueswir1
deletes a snapshot
66 d2c639d6 blueswir1
@item -l
67 d2c639d6 blueswir1
lists all snapshots in the given image
68 acd935ef bellard
@end table
69 acd935ef bellard
70 acd935ef bellard
Command description:
71 acd935ef bellard
72 acd935ef bellard
@table @option
73 4534ff54 Kevin Wolf
@item check [-f @var{fmt}] [-r [leaks | all]] @var{filename}
74 e6184690 Kevin Wolf
75 e6184690 Kevin Wolf
Perform a consistency check on the disk image @var{filename}.
76 e6184690 Kevin Wolf
77 4534ff54 Kevin Wolf
If @code{-r} is specified, qemu-img tries to repair any inconsistencies found
78 4534ff54 Kevin Wolf
during the check. @code{-r leaks} repairs only cluster leaks, whereas
79 4534ff54 Kevin Wolf
@code{-r all} fixes all kinds of errors, with a higher risk of choosing the
80 4534ff54 Kevin Wolf
wrong fix or hiding corruption that has already occured.
81 4534ff54 Kevin Wolf
82 e6184690 Kevin Wolf
Only the formats @code{qcow2}, @code{qed} and @code{vdi} support
83 e6184690 Kevin Wolf
consistency checks.
84 e6184690 Kevin Wolf
85 8063d0fe Kevin Wolf
@item create [-f @var{fmt}] [-o @var{options}] @var{filename} [@var{size}]
86 acd935ef bellard
87 acd935ef bellard
Create the new disk image @var{filename} of size @var{size} and format
88 8063d0fe Kevin Wolf
@var{fmt}. Depending on the file format, you can add one or more @var{options}
89 8063d0fe Kevin Wolf
that enable additional features of this format.
90 acd935ef bellard
91 8063d0fe Kevin Wolf
If the option @var{backing_file} is specified, then the image will record
92 8063d0fe Kevin Wolf
only the differences from @var{backing_file}. No size needs to be specified in
93 8063d0fe Kevin Wolf
this case. @var{backing_file} will never be modified unless you use the
94 8063d0fe Kevin Wolf
@code{commit} monitor command (or qemu-img commit).
95 acd935ef bellard
96 eff44266 Kevin Wolf
The size can also be specified using the @var{size} option with @code{-o},
97 eff44266 Kevin Wolf
it doesn't need to be specified separately in this case.
98 eff44266 Kevin Wolf
99 3763f26f Kevin Wolf
@item commit [-f @var{fmt}] [-t @var{cache}] @var{filename}
100 acd935ef bellard
101 acd935ef bellard
Commit the changes recorded in @var{filename} in its base image.
102 acd935ef bellard
103 3763f26f Kevin Wolf
@item convert [-c] [-p] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
104 acd935ef bellard
105 51ef6727 edison
Convert the disk image @var{filename} or a snapshot @var{snapshot_name} to disk image @var{output_filename}
106 eff44266 Kevin Wolf
using format @var{output_fmt}. It can be optionally compressed (@code{-c}
107 eff44266 Kevin Wolf
option) or use any format specific options like encryption (@code{-o} option).
108 acd935ef bellard
109 8063d0fe Kevin Wolf
Only the formats @code{qcow} and @code{qcow2} support compression. The
110 acd935ef bellard
compression is read-only. It means that if a compressed sector is
111 acd935ef bellard
rewritten, then it is rewritten as uncompressed data.
112 acd935ef bellard
113 acd935ef bellard
Image conversion is also useful to get smaller image when using a
114 acd935ef bellard
growable format such as @code{qcow} or @code{cow}: the empty sectors
115 acd935ef bellard
are detected and suppressed from the destination image.
116 acd935ef bellard
117 8063d0fe Kevin Wolf
You can use the @var{backing_file} option to force the output image to be
118 8063d0fe Kevin Wolf
created as a copy on write image of the specified base image; the
119 8063d0fe Kevin Wolf
@var{backing_file} should have the same content as the input's base image,
120 8063d0fe Kevin Wolf
however the path, image format, etc may differ.
121 8063d0fe Kevin Wolf
122 acd935ef bellard
@item info [-f @var{fmt}] @var{filename}
123 acd935ef bellard
124 acd935ef bellard
Give information about the disk image @var{filename}. Use it in
125 acd935ef bellard
particular to know the size reserved on disk which can be different
126 19d36792 bellard
from the displayed size. If VM snapshots are stored in the disk image,
127 19d36792 bellard
they are displayed too.
128 d2c639d6 blueswir1
129 d2c639d6 blueswir1
@item snapshot [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot} ] @var{filename}
130 d2c639d6 blueswir1
131 d2c639d6 blueswir1
List, apply, create or delete snapshots in image @var{filename}.
132 ae6b0ed6 Stefan Hajnoczi
133 3763f26f Kevin Wolf
@item rebase [-f @var{fmt}] [-t @var{cache}] [-p] [-u] -b @var{backing_file} [-F @var{backing_fmt}] @var{filename}
134 e6184690 Kevin Wolf
135 e6184690 Kevin Wolf
Changes the backing file of an image. Only the formats @code{qcow2} and
136 e6184690 Kevin Wolf
@code{qed} support changing the backing file.
137 e6184690 Kevin Wolf
138 e6184690 Kevin Wolf
The backing file is changed to @var{backing_file} and (if the image format of
139 e6184690 Kevin Wolf
@var{filename} supports this) the backing file format is changed to
140 e6184690 Kevin Wolf
@var{backing_fmt}.
141 e6184690 Kevin Wolf
142 e6184690 Kevin Wolf
There are two different modes in which @code{rebase} can operate:
143 e6184690 Kevin Wolf
@table @option
144 e6184690 Kevin Wolf
@item Safe mode
145 e6184690 Kevin Wolf
This is the default mode and performs a real rebase operation. The new backing
146 e6184690 Kevin Wolf
file may differ from the old one and qemu-img rebase will take care of keeping
147 e6184690 Kevin Wolf
the guest-visible content of @var{filename} unchanged.
148 e6184690 Kevin Wolf
149 e6184690 Kevin Wolf
In order to achieve this, any clusters that differ between @var{backing_file}
150 e6184690 Kevin Wolf
and the old backing file of @var{filename} are merged into @var{filename}
151 e6184690 Kevin Wolf
before actually changing the backing file.
152 e6184690 Kevin Wolf
153 e6184690 Kevin Wolf
Note that the safe mode is an expensive operation, comparable to converting
154 e6184690 Kevin Wolf
an image. It only works if the old backing file still exists.
155 e6184690 Kevin Wolf
156 e6184690 Kevin Wolf
@item Unsafe mode
157 e6184690 Kevin Wolf
qemu-img uses the unsafe mode if @code{-u} is specified. In this mode, only the
158 e6184690 Kevin Wolf
backing file name and format of @var{filename} is changed without any checks
159 e6184690 Kevin Wolf
on the file contents. The user must take care of specifying the correct new
160 e6184690 Kevin Wolf
backing file, or the guest-visible content of the image will be corrupted.
161 e6184690 Kevin Wolf
162 e6184690 Kevin Wolf
This mode is useful for renaming or moving the backing file to somewhere else.
163 e6184690 Kevin Wolf
It can be used without an accessible old backing file, i.e. you can use it to
164 e6184690 Kevin Wolf
fix an image whose backing file has already been moved/renamed.
165 e6184690 Kevin Wolf
@end table
166 e6184690 Kevin Wolf
167 9fda6ab1 Richard W.M. Jones
You can use @code{rebase} to perform a ``diff'' operation on two
168 9fda6ab1 Richard W.M. Jones
disk images.  This can be useful when you have copied or cloned
169 9fda6ab1 Richard W.M. Jones
a guest, and you want to get back to a thin image on top of a
170 9fda6ab1 Richard W.M. Jones
template or base image.
171 9fda6ab1 Richard W.M. Jones
172 9fda6ab1 Richard W.M. Jones
Say that @code{base.img} has been cloned as @code{modified.img} by
173 9fda6ab1 Richard W.M. Jones
copying it, and that the @code{modified.img} guest has run so there
174 9fda6ab1 Richard W.M. Jones
are now some changes compared to @code{base.img}.  To construct a thin
175 9fda6ab1 Richard W.M. Jones
image called @code{diff.qcow2} that contains just the differences, do:
176 9fda6ab1 Richard W.M. Jones
177 9fda6ab1 Richard W.M. Jones
@example
178 9fda6ab1 Richard W.M. Jones
qemu-img create -f qcow2 -b modified.img diff.qcow2
179 9fda6ab1 Richard W.M. Jones
qemu-img rebase -b base.img diff.qcow2
180 9fda6ab1 Richard W.M. Jones
@end example
181 9fda6ab1 Richard W.M. Jones
182 9fda6ab1 Richard W.M. Jones
At this point, @code{modified.img} can be discarded, since
183 9fda6ab1 Richard W.M. Jones
@code{base.img + diff.qcow2} contains the same information.
184 9fda6ab1 Richard W.M. Jones
185 ae6b0ed6 Stefan Hajnoczi
@item resize @var{filename} [+ | -]@var{size}
186 ae6b0ed6 Stefan Hajnoczi
187 ae6b0ed6 Stefan Hajnoczi
Change the disk image as if it had been created with @var{size}.
188 ae6b0ed6 Stefan Hajnoczi
189 ae6b0ed6 Stefan Hajnoczi
Before using this command to shrink a disk image, you MUST use file system and
190 ae6b0ed6 Stefan Hajnoczi
partitioning tools inside the VM to reduce allocated file systems and partition
191 ae6b0ed6 Stefan Hajnoczi
sizes accordingly.  Failure to do so will result in data loss!
192 ae6b0ed6 Stefan Hajnoczi
193 ae6b0ed6 Stefan Hajnoczi
After using this command to grow a disk image, you must use file system and
194 ae6b0ed6 Stefan Hajnoczi
partitioning tools inside the VM to actually begin using the new space on the
195 ae6b0ed6 Stefan Hajnoczi
device.
196 acd935ef bellard
@end table
197 acd935ef bellard
198 f932c040 Kevin Wolf
Supported image file formats:
199 f932c040 Kevin Wolf
200 f932c040 Kevin Wolf
@table @option
201 f932c040 Kevin Wolf
@item raw
202 f932c040 Kevin Wolf
203 f932c040 Kevin Wolf
Raw disk image format (default). This format has the advantage of
204 f932c040 Kevin Wolf
being simple and easily exportable to all other emulators. If your
205 f932c040 Kevin Wolf
file system supports @emph{holes} (for example in ext2 or ext3 on
206 f932c040 Kevin Wolf
Linux or NTFS on Windows), then only the written sectors will reserve
207 f932c040 Kevin Wolf
space. Use @code{qemu-img info} to know the real size used by the
208 f932c040 Kevin Wolf
image or @code{ls -ls} on Unix/Linux.
209 f932c040 Kevin Wolf
210 f932c040 Kevin Wolf
@item qcow2
211 f932c040 Kevin Wolf
QEMU image format, the most versatile format. Use it to have smaller
212 f932c040 Kevin Wolf
images (useful if your filesystem does not supports holes, for example
213 f932c040 Kevin Wolf
on Windows), optional AES encryption, zlib based compression and
214 f932c040 Kevin Wolf
support of multiple VM snapshots.
215 8063d0fe Kevin Wolf
216 3e032364 Kevin Wolf
Supported options:
217 3e032364 Kevin Wolf
@table @code
218 3e032364 Kevin Wolf
@item backing_file
219 3e032364 Kevin Wolf
File name of a base image (see @option{create} subcommand)
220 3e032364 Kevin Wolf
@item backing_fmt
221 3e032364 Kevin Wolf
Image format of the base image
222 3e032364 Kevin Wolf
@item encryption
223 3e032364 Kevin Wolf
If this option is set to @code{on}, the image is encrypted.
224 3e032364 Kevin Wolf
225 8063d0fe Kevin Wolf
Encryption uses the AES format which is very secure (128 bit keys). Use
226 8063d0fe Kevin Wolf
a long password (16 characters) to get maximum protection.
227 3e032364 Kevin Wolf
228 3e032364 Kevin Wolf
@item cluster_size
229 3e032364 Kevin Wolf
Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster
230 3e032364 Kevin Wolf
sizes can improve the image file size whereas larger cluster sizes generally
231 3e032364 Kevin Wolf
provide better performance.
232 3e032364 Kevin Wolf
233 3e032364 Kevin Wolf
@item preallocation
234 3e032364 Kevin Wolf
Preallocation mode (allowed values: off, metadata). An image with preallocated
235 3e032364 Kevin Wolf
metadata is initially larger but can improve performance when the image needs
236 3e032364 Kevin Wolf
to grow.
237 3e032364 Kevin Wolf
238 3e032364 Kevin Wolf
@end table
239 3e032364 Kevin Wolf
240 f085800e Stefan Hajnoczi
@item qed
241 f085800e Stefan Hajnoczi
Image format with support for backing files and compact image files (when your
242 f085800e Stefan Hajnoczi
filesystem or transport medium does not support holes).  Good performance due
243 f085800e Stefan Hajnoczi
to less metadata than the more featureful qcow2 format, especially with
244 f085800e Stefan Hajnoczi
cache=writethrough or cache=directsync.  Consider using qcow2 which will soon
245 f085800e Stefan Hajnoczi
have a similar optimization and is most actively developed.
246 f085800e Stefan Hajnoczi
247 f085800e Stefan Hajnoczi
Supported options:
248 f085800e Stefan Hajnoczi
@table @code
249 f085800e Stefan Hajnoczi
@item backing_file
250 f085800e Stefan Hajnoczi
File name of a base image (see @option{create} subcommand).
251 f085800e Stefan Hajnoczi
@item backing_fmt
252 f085800e Stefan Hajnoczi
Image file format of backing file (optional).  Useful if the format cannot be
253 f085800e Stefan Hajnoczi
autodetected because it has no header, like some vhd/vpc files.
254 f085800e Stefan Hajnoczi
@item cluster_size
255 f085800e Stefan Hajnoczi
Changes the cluster size (must be power-of-2 between 4K and 64K). Smaller
256 f085800e Stefan Hajnoczi
cluster sizes can improve the image file size whereas larger cluster sizes
257 f085800e Stefan Hajnoczi
generally provide better performance.
258 f085800e Stefan Hajnoczi
@item table_size
259 f085800e Stefan Hajnoczi
Changes the number of clusters per L1/L2 table (must be power-of-2 between 1
260 f085800e Stefan Hajnoczi
and 16).  There is normally no need to change this value but this option can be
261 f085800e Stefan Hajnoczi
used for performance benchmarking.
262 f085800e Stefan Hajnoczi
@end table
263 3e032364 Kevin Wolf
264 f932c040 Kevin Wolf
@item qcow
265 f932c040 Kevin Wolf
Old QEMU image format. Left for compatibility.
266 3e032364 Kevin Wolf
267 3e032364 Kevin Wolf
Supported options:
268 3e032364 Kevin Wolf
@table @code
269 3e032364 Kevin Wolf
@item backing_file
270 3e032364 Kevin Wolf
File name of a base image (see @option{create} subcommand)
271 3e032364 Kevin Wolf
@item encryption
272 3e032364 Kevin Wolf
If this option is set to @code{on}, the image is encrypted.
273 3e032364 Kevin Wolf
@end table
274 3e032364 Kevin Wolf
275 f932c040 Kevin Wolf
@item cow
276 f932c040 Kevin Wolf
User Mode Linux Copy On Write image format. Used to be the only growable
277 f932c040 Kevin Wolf
image format in QEMU. It is supported only for compatibility with
278 f932c040 Kevin Wolf
previous versions. It does not work on win32.
279 f932c040 Kevin Wolf
@item vdi
280 f932c040 Kevin Wolf
VirtualBox 1.1 compatible image format.
281 f932c040 Kevin Wolf
@item vmdk
282 f932c040 Kevin Wolf
VMware 3 and 4 compatible image format.
283 3e032364 Kevin Wolf
284 3e032364 Kevin Wolf
Supported options:
285 3e032364 Kevin Wolf
@table @code
286 3e032364 Kevin Wolf
@item backing_fmt
287 3e032364 Kevin Wolf
Image format of the base image
288 3e032364 Kevin Wolf
@item compat6
289 3e032364 Kevin Wolf
Create a VMDK version 6 image (instead of version 4)
290 3e032364 Kevin Wolf
@end table
291 3e032364 Kevin Wolf
292 3e032364 Kevin Wolf
@item vpc
293 3e032364 Kevin Wolf
VirtualPC compatible image format (VHD).
294 3e032364 Kevin Wolf
295 f932c040 Kevin Wolf
@item cloop
296 f932c040 Kevin Wolf
Linux Compressed Loop image, useful only to reuse directly compressed
297 f932c040 Kevin Wolf
CD-ROM images present for example in the Knoppix CD-ROMs.
298 f932c040 Kevin Wolf
@end table
299 f932c040 Kevin Wolf
300 f932c040 Kevin Wolf
301 acd935ef bellard
@c man end
302 acd935ef bellard
303 acd935ef bellard
@ignore
304 acd935ef bellard
305 acd935ef bellard
@setfilename qemu-img
306 acd935ef bellard
@settitle QEMU disk image utility
307 acd935ef bellard
308 acd935ef bellard
@c man begin SEEALSO
309 acd935ef bellard
The HTML documentation of QEMU for more precise information and Linux
310 acd935ef bellard
user mode emulator invocation.
311 acd935ef bellard
@c man end
312 acd935ef bellard
313 acd935ef bellard
@c man begin AUTHOR
314 acd935ef bellard
Fabrice Bellard
315 acd935ef bellard
@c man end
316 acd935ef bellard
317 acd935ef bellard
@end ignore