Statistics
| Branch: | Revision:

root / qemu-img.texi @ 45724d6d

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