1virt-sparsify(1)            Virtualization Support            virt-sparsify(1)
2
3
4

NAME

6       virt-sparsify - Make a virtual machine disk sparse
7

SYNOPSIS

9        virt-sparsify [--options] indisk outdisk
10

DESCRIPTION

12       Virt-sparsify is a tool which can make a virtual machine disk (or any
13       disk image) sparse a.k.a. thin-provisioned.  This means that free space
14       within the disk image can be converted back to free space on the host.
15
16       Virt-sparsify can locate and sparsify free space in most filesystems
17       (eg. ext2/3/4, btrfs, NTFS, etc.), and also in LVM physical volumes.
18
19       Virt-sparsify can also convert between some disk formats, for example
20       converting a raw disk image to a thin-provisioned qcow2 image.
21
22       Virt-sparsify can operate on any disk image, not just ones from virtual
23       machines.  However if a virtual machine has multiple disks and uses
24       volume management, then virt-sparsify will work but not be very
25       effective (http://bugzilla.redhat.com/887826).
26
27   IMPORTANT NOTE ABOUT SPARSE OUTPUT IMAGES
28       If the input is raw, then the default output is raw sparse.  You must
29       check the output size using a tool that understands sparseness such as
30       "du -sh".  It can make a huge difference:
31
32        $ ls -lh test1.img
33        -rw-rw-r--. 1 rjones rjones 100M Aug  8 08:08 test1.img
34        $ du -sh test1.img
35        3.6M   test1.img
36
37       (Compare the apparent size 100M vs the actual size 3.6M)
38
39   IMPORTANT LIMITATIONS
40       ·   Virt-sparsify does not do in-place modifications.  It copies from a
41           source image to a destination image, leaving the source unchanged.
42           Check that the sparsification was successful before deleting the
43           source image.
44
45       ·   The virtual machine must be shut down before using this tool.
46
47       ·   Virt-sparsify may require up to 2x the virtual size of the source
48           disk image (1 temporary copy + 1 destination image).  This is in
49           the worst case and usually much less space is required.
50
51       ·   Virt-sparsify cannot resize disk images.  To do that, use
52           virt-resize(1).
53
54       ·   Virt-sparsify cannot handle encrypted disks.  Libguestfs supports
55           encrypted disks, but encrypted disks themselves cannot be
56           sparsified.
57
58       ·   Virt-sparsify cannot yet sparsify the space between partitions.
59           Note that this space is often used for critical items like
60           bootloaders so it's not really unused.
61
62       You may also want to read the manual pages for the associated tools
63       virt-filesystems(1) and virt-df(1) before starting.
64

EXAMPLES

66       Typical usage is:
67
68        virt-sparsify indisk outdisk
69
70       which copies "indisk" to "outdisk", making the output sparse.
71       "outdisk" is created, or overwritten if it already exists.  The format
72       of the input disk is detected (eg. qcow2) and the same format is used
73       for the output disk.
74
75       To convert between formats, use the --convert option:
76
77        virt-sparsify disk.raw --convert qcow2 disk.qcow2
78
79       Virt-sparsify tries to zero and sparsify free space on every filesystem
80       it can find within the source disk image.  You can get it to ignore
81       (don't zero free space on) certain filesystems by doing:
82
83        virt-sparsify --ignore /dev/sda1 indisk outdisk
84
85       See virt-filesystems(1) to get a list of filesystems within a disk
86       image.
87

OPTIONS

89       --help
90           Display help.
91
92       --check-tmpdir=ignore
93       --check-tmpdir=continue
94       --check-tmpdir=warn
95       --check-tmpdir=fail
96           Check if "TMPDIR" or --tmp directory has enough space to complete
97           the operation.  This is just an estimate.
98
99           If the check indicates a problem, then you can either:
100
101           ·   ignore it,
102
103           ·   print a warning and continue,
104
105           ·   warn and wait for the user to press the Return key (this is the
106               default), or:
107
108           ·   fail and exit.
109
110       --compress
111           Compress the output file.  This only works if the output format is
112           "qcow2".
113
114       --convert raw
115       --convert qcow2
116       --convert [other formats]
117           Use "output-format" as the format for the destination image.  If
118           this is not specified, then the input format is used.
119
120           Supported and known-working output formats are: "raw", "qcow2",
121           "vdi".
122
123           You can also use any format supported by the qemu-img(1) program,
124           eg. "vmdk", but support for other formats is reliant on qemu.
125
126           Specifying the --convert option is usually a good idea, because
127           then virt-sparsify doesn't need to try to guess the input format.
128
129           For fine-tuning the output format, see: --compress, -o.
130
131       --debug-gc
132           Debug garbage collection and memory allocation.  This is only
133           useful when debugging memory problems in virt-sparsify or the OCaml
134           libguestfs bindings.
135
136       --format raw
137       --format qcow2
138           Specify the format of the input disk image.  If this flag is not
139           given then it is auto-detected from the image itself.
140
141           If working with untrusted raw-format guest disk images, you should
142           ensure the format is always specified.
143
144       --ignore filesystem
145       --ignore volgroup
146           Ignore the named filesystem.  Free space on the filesystem will not
147           be zeroed, but existing blocks of zeroes will still be sparsified.
148
149           In the second form, this ignores the named volume group.  Use the
150           volume group name without the "/dev/" prefix, eg. --ignore vg_foo
151
152           You can give this option multiple times.
153
154       --machine-readable
155           This option is used to make the output more machine friendly when
156           being parsed by other programs.  See "MACHINE READABLE OUTPUT"
157           below.
158
159       -o option[,option,...]
160           Pass -o option(s) to the qemu-img(1) command to fine-tune the
161           output format.  Options available depend on the output format (see
162           --convert) and the installed version of the qemu-img program.
163
164           You should use -o at most once.  To pass multiple options, separate
165           them with commas, eg:
166
167            virt-sparsify --convert qcow2 \
168              -o cluster_size=512,preallocation=metadata ...
169
170       -q
171       --quiet
172           This disables progress bars and other unnecessary output.
173
174       --tmp block_device
175       --tmp dir
176           In copying mode only, use the named device or directory as the
177           location of the temporary overlay (see also "TMPDIR" below).
178
179           If the parameter given is a block device, then the block device is
180           written to directly.  Note this erases the existing contents of the
181           block device.
182
183           If the parameter is a directory, then this is the same as setting
184           the "TMPDIR" environment variable.
185
186       --tmp prebuilt:file
187           In copying mode only, the specialized option --tmp prebuilt:file
188           (where "prebuilt:" is a literal string) causes virt-sparsify to use
189           the qcow2 "file" as temporary space.
190
191           ·   The file must be freshly formatted as qcow2, with indisk as the
192               backing file.
193
194           ·   If you rerun virt-sparsify, you must recreate the file before
195               each run.
196
197           ·   Virt-sparsify does not delete the file.
198
199           This option is used by oVirt which requires a specially formatted
200           temporary file.
201
202       -v
203       --verbose
204           Enable verbose messages for debugging.
205
206       -V
207       --version
208           Display version number and exit.
209
210       -x  Enable tracing of libguestfs API calls.
211
212       --zero partition
213       --zero logvol
214           Zero the contents of the named partition or logical volume in the
215           guest.  All data on the device is lost, but sparsification is
216           excellent!  You can give this option multiple times.
217

MACHINE READABLE OUTPUT

219       The --machine-readable option can be used to make the output more
220       machine friendly, which is useful when calling virt-sparsify from other
221       programs, GUIs etc.
222
223       There are two ways to use this option.
224
225       Firstly use the option on its own to query the capabilities of the
226       virt-sparsify binary.  Typical output looks like this:
227
228        $ virt-sparsify --machine-readable
229        virt-sparsify
230        ntfs
231        btrfs
232
233       A list of features is printed, one per line, and the program exits with
234       status 0.
235
236       Secondly use the option in conjunction with other options to make the
237       regular program output more machine friendly.
238
239       At the moment this means:
240
241       1.  Progress bar messages can be parsed from stdout by looking for this
242           regular expression:
243
244            ^[0-9]+/[0-9]+$
245
246       2.  The calling program should treat messages sent to stdout (except
247           for progress bar messages) as status messages.  They can be logged
248           and/or displayed to the user.
249
250       3.  The calling program should treat messages sent to stderr as error
251           messages.  In addition, virt-sparsify exits with a non-zero status
252           code if there was a fatal error.
253
254       All versions of virt-sparsify have supported the --machine-readable
255       option.
256

WINDOWS 8

258       Windows 8 "fast startup" can prevent virt-sparsify from working.  See
259       "WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP" in guestfs(3).
260

EXIT STATUS

262       This program returns 0 if successful, or non-zero if there was an
263       error.
264

ENVIRONMENT VARIABLES

266       TMPDIR
267           Location of the temporary directory used for the potentially large
268           temporary overlay file.
269
270           You can override this environment variable using the --tmp option.
271
272           You should ensure there is enough free space in the worst case for
273           a full copy of the source disk (virtual size), or else set $TMPDIR
274           to point to another directory that has enough space.
275
276           This defaults to "/tmp".
277
278           Note that if $TMPDIR is a tmpfs (eg. if "/tmp" is on tmpfs, or if
279           you use "TMPDIR=/dev/shm"), tmpfs defaults to a maximum size of
280           half of physical RAM.  If virt-sparsify exceeds this, it will hang.
281           The solution is either to use a real disk, or to increase the
282           maximum size of the tmpfs mountpoint, eg:
283
284            mount -o remount,size=10G /tmp
285
286       For other environment variables, see "ENVIRONMENT VARIABLES" in
287       guestfs(3).
288

SEE ALSO

290       virt-filesystems(1), virt-df(1), virt-resize(1), virt-rescue(1),
291       guestfs(3), guestfish(1), truncate(1), fallocate(1), qemu-img(1),
292       http://libguestfs.org/.
293

AUTHOR

295       Richard W.M. Jones http://people.redhat.com/~rjones/
296
298       Copyright (C) 2011-2012 Red Hat Inc.
299

LICENSE

301       This program is free software; you can redistribute it and/or modify it
302       under the terms of the GNU General Public License as published by the
303       Free Software Foundation; either version 2 of the License, or (at your
304       option) any later version.
305
306       This program is distributed in the hope that it will be useful, but
307       WITHOUT ANY WARRANTY; without even the implied warranty of
308       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
309       General Public License for more details.
310
311       You should have received a copy of the GNU General Public License along
312       with this program; if not, write to the Free Software Foundation, Inc.,
313       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
314

BUGS

316       To get a list of bugs against libguestfs, use this link:
317       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
318
319       To report a new bug against libguestfs, use this link:
320       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
321
322       When reporting a bug, please supply:
323
324       ·   The version of libguestfs.
325
326       ·   Where you got libguestfs (eg. which Linux distro, compiled from
327           source, etc)
328
329       ·   Describe the bug accurately and give a way to reproduce it.
330
331       ·   Run libguestfs-test-tool(1) and paste the complete, unedited output
332           into the bug report.
333
334
335
336libguestfs-1.20.11                2013-08-27                  virt-sparsify(1)
Impressum