.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" ======================================================================== .\" .IX Title "virt-sparsify 1" .TH virt-sparsify 1 "2013-12-07" "libguestfs-1.18.1" "Virtualization Support" .\" 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" virt\-sparsify \- Make a virtual machine disk sparse .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& virt\-sparsify [\-\-options] indisk outdisk .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Virt-sparsify is a tool which can make a virtual machine disk (or any disk image) sparse a.k.a. thin-provisioned. This means that free space within the disk image can be converted back to free space on the host. .PP Virt-sparsify can locate and sparsify free space in most filesystems (eg. ext2/3/4, btrfs, \s-1NTFS\s0, etc.), and also in \s-1LVM\s0 physical volumes. .PP Virt-sparsify can also convert between some disk formats, for example converting a raw disk image to a thin-provisioned qcow2 image. .PP Virt-sparsify can operate on any disk image, not just ones from virtual machines. If a virtual machine has more than one attached disk, you must sparsify each one separately. .SS "\s-1IMPORTANT\s0 \s-1LIMITATIONS\s0" .IX Subsection "IMPORTANT LIMITATIONS" .IP "\(bu" 4 Virt-sparsify does not do in-place modifications. It copies from a source image to a destination image, leaving the source unchanged. \&\fICheck that the sparsification was successful before deleting the source image\fR. .IP "\(bu" 4 The virtual machine \fImust be shut down\fR before using this tool. .IP "\(bu" 4 Virt-sparsify may require up to 2x the virtual size of the source disk image (1 temporary copy + 1 destination image). This is in the worst case and usually much less space is required. .IP "\(bu" 4 Virt-sparsify cannot resize disk images. To do that, use \&\fIvirt\-resize\fR\|(1). .IP "\(bu" 4 Virt-sparsify cannot handle encrypted disks. Libguestfs supports encrypted disks, but encrypted disks themselves cannot be sparsified. .IP "\(bu" 4 Virt-sparsify cannot yet sparsify the space between partitions. Note that this space is often used for critical items like bootloaders so it's not really unused. .PP You may also want to read the manual pages for the associated tools \&\fIvirt\-filesystems\fR\|(1) and \fIvirt\-df\fR\|(1) before starting. .SH "EXAMPLES" .IX Header "EXAMPLES" Typical usage is: .PP .Vb 1 \& virt\-sparsify indisk outdisk .Ve .PP which copies \f(CW\*(C`indisk\*(C'\fR to \f(CW\*(C`outdisk\*(C'\fR, making the output sparse. \&\f(CW\*(C`outdisk\*(C'\fR is created, or overwritten if it already exists. The format of the input disk is detected (eg. qcow2) and the same format is used for the output disk. .PP To convert between formats, use the \fI\-\-convert\fR option: .PP .Vb 1 \& virt\-sparsify disk.raw \-\-convert qcow2 disk.qcow2 .Ve .PP Virt-sparsify tries to zero and sparsify free space on every filesystem it can find within the source disk image. You can get it to ignore (don't zero free space on) certain filesystems by doing: .PP .Vb 1 \& virt\-sparsify \-\-ignore /dev/sda1 indisk outdisk .Ve .PP See \fIvirt\-filesystems\fR\|(1) to get a list of filesystems within a disk image. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-\-help\fR" 4 .IX Item "--help" Display help. .IP "\fB\-\-compress\fR" 4 .IX Item "--compress" Compress the output file. This \fIonly\fR works if the output format is \&\f(CW\*(C`qcow2\*(C'\fR. .IP "\fB\-\-convert\fR raw" 4 .IX Item "--convert raw" .PD 0 .IP "\fB\-\-convert\fR qcow2" 4 .IX Item "--convert qcow2" .IP "\fB\-\-convert\fR [other formats]" 4 .IX Item "--convert [other formats]" .PD Use \f(CW\*(C`output\-format\*(C'\fR as the format for the destination image. If this is not specified, then the input format is used. .Sp Supported and known-working output formats are: \f(CW\*(C`raw\*(C'\fR, \f(CW\*(C`qcow2\*(C'\fR, \f(CW\*(C`vdi\*(C'\fR. .Sp You can also use any format supported by the \fIqemu\-img\fR\|(1) program, eg. \f(CW\*(C`vmdk\*(C'\fR, but support for other formats is reliant on qemu. .Sp Specifying the \fI\-\-convert\fR option is usually a good idea, because then virt-sparsify doesn't need to try to guess the input format. .Sp For fine-tuning the output format, see: \fI\-\-compress\fR, \fI\-o\fR. .IP "\fB\-\-debug\-gc\fR" 4 .IX Item "--debug-gc" Debug garbage collection and memory allocation. This is only useful when debugging memory problems in virt-sparsify or the OCaml libguestfs bindings. .IP "\fB\-\-format\fR raw" 4 .IX Item "--format raw" .PD 0 .IP "\fB\-\-format\fR qcow2" 4 .IX Item "--format qcow2" .PD Specify the format of the input disk image. If this flag is not given then it is auto-detected from the image itself. .Sp If working with untrusted raw-format guest disk images, you should ensure the format is always specified. .IP "\fB\-\-ignore\fR filesystem" 4 .IX Item "--ignore filesystem" .PD 0 .IP "\fB\-\-ignore\fR volgroup" 4 .IX Item "--ignore volgroup" .PD Ignore the named filesystem. Free space on the filesystem will not be zeroed, but existing blocks of zeroes will still be sparsified. .Sp In the second form, this ignores the named volume group. Use the volume group name without the \f(CW\*(C`/dev/\*(C'\fR prefix, eg. \fI\-\-ignore vg_foo\fR .Sp You can give this option multiple times. .IP "\fB\-\-machine\-readable\fR" 4 .IX Item "--machine-readable" This option is used to make the output more machine friendly when being parsed by other programs. See \&\*(L"\s-1MACHINE\s0 \s-1READABLE\s0 \s-1OUTPUT\s0\*(R" below. .IP "\fB\-o\fR option[,option,...]" 4 .IX Item "-o option[,option,...]" Pass \fI\-o\fR option(s) to the \fIqemu\-img\fR\|(1) command to fine-tune the output format. Options available depend on the output format (see \&\fI\-\-convert\fR) and the installed version of the qemu-img program. .Sp You should use \fI\-o\fR at most once. To pass multiple options, separate them with commas, eg: .Sp .Vb 2 \& virt\-sparsify \-\-convert qcow2 \e \& \-o cluster_size=512,preallocation=metadata ... .Ve .IP "\fB\-q\fR" 4 .IX Item "-q" .PD 0 .IP "\fB\-\-quiet\fR" 4 .IX Item "--quiet" .PD This disables progress bars and other unnecessary output. .IP "\fB\-v\fR" 4 .IX Item "-v" .PD 0 .IP "\fB\-\-verbose\fR" 4 .IX Item "--verbose" .PD Enable verbose messages for debugging. .IP "\fB\-V\fR" 4 .IX Item "-V" .PD 0 .IP "\fB\-\-version\fR" 4 .IX Item "--version" .PD Display version number and exit. .IP "\fB\-x\fR" 4 .IX Item "-x" Enable tracing of libguestfs \s-1API\s0 calls. .IP "\fB\-\-zero\fR partition" 4 .IX Item "--zero partition" .PD 0 .IP "\fB\-\-zero\fR logvol" 4 .IX Item "--zero logvol" .PD Zero the contents of the named partition or logical volume in the guest. All data on the device is lost, but sparsification is excellent! You can give this option multiple times. .SH "MACHINE READABLE OUTPUT" .IX Header "MACHINE READABLE OUTPUT" The \fI\-\-machine\-readable\fR option can be used to make the output more machine friendly, which is useful when calling virt-sparsify from other programs, GUIs etc. .PP There are two ways to use this option. .PP Firstly use the option on its own to query the capabilities of the virt-sparsify binary. Typical output looks like this: .PP .Vb 4 \& $ virt\-sparsify \-\-machine\-readable \& virt\-sparsify \& ntfs \& btrfs .Ve .PP A list of features is printed, one per line, and the program exits with status 0. .PP Secondly use the option in conjunction with other options to make the regular program output more machine friendly. .PP At the moment this means: .IP "1." 4 Progress bar messages can be parsed from stdout by looking for this regular expression: .Sp .Vb 1 \& ^[0\-9]+/[0\-9]+$ .Ve .IP "2." 4 The calling program should treat messages sent to stdout (except for progress bar messages) as status messages. They can be logged and/or displayed to the user. .IP "3." 4 The calling program should treat messages sent to stderr as error messages. In addition, virt-sparsify exits with a non-zero status code if there was a fatal error. .PP All versions of virt-sparsify have supported the \fI\-\-machine\-readable\fR option. .SH "EXIT STATUS" .IX Header "EXIT STATUS" This program returns 0 if successful, or non-zero if there was an error. .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" .IP "\s-1TMPDIR\s0" 4 .IX Item "TMPDIR" Location of the temporary directory used for the potentially large temporary overlay file. .Sp You should ensure there is enough free space in the worst case for a full copy of the source disk (\fIvirtual\fR size), or else set \f(CW$TMPDIR\fR to point to another directory that has enough space. .Sp This defaults to \f(CW\*(C`/tmp\*(C'\fR. .Sp Note that if \f(CW$TMPDIR\fR is a tmpfs (eg. if \f(CW\*(C`/tmp\*(C'\fR is on tmpfs, or if you use \f(CW\*(C`TMPDIR=/dev/shm\*(C'\fR), tmpfs defaults to a maximum size of \&\fIhalf\fR of physical \s-1RAM\s0. If virt-sparsify exceeds this, it will hang. The solution is either to use a real disk, or to increase the maximum size of the tmpfs mountpoint, eg: .Sp .Vb 1 \& mount \-o remount,size=10G /tmp .Ve .PP For other environment variables, see \*(L"\s-1ENVIRONMENT\s0 \s-1VARIABLES\s0\*(R" in \fIguestfs\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIvirt\-filesystems\fR\|(1), \&\fIvirt\-df\fR\|(1), \&\fIvirt\-resize\fR\|(1), \&\fIvirt\-rescue\fR\|(1), \&\fIguestfs\fR\|(3), \&\fIguestfish\fR\|(1), \&\fItruncate\fR\|(1), \&\fIfallocate\fR\|(1), \&\fIqemu\-img\fR\|(1), . .SH "AUTHOR" .IX Header "AUTHOR" Richard W.M. Jones .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2011 Red Hat Inc. .PP This program is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the \&\s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, \s-1MA\s0 02110\-1301 \s-1USA\s0.