LinuxCommandLibrary

virt-sparsify

Compact VM disk image files

TLDR

Create compressed sparse image

$ virt-sparsify --compress [path/to/image.qcow2] [path/to/new_image.qcow2]
copy
Sparsify in-place
$ virt-sparsify --in-place [path/to/image.img]
copy
Convert format
$ virt-sparsify [path/to/image] --convert [qcow2|raw|vdi] [path/to/new_image]
copy

SYNOPSIS

virt-sparsify [OPTIONS] INPUT OUTPUT

DESCRIPTION

virt-sparsify makes virtual machine disk images thin-provisioned by removing unused space and creating sparse files. This can significantly reduce disk image file sizes.
The tool reclaims space by zeroing free blocks within the guest filesystem and then creating a sparse copy.

PARAMETERS

--compress

Compress output file
--in-place
Sparsify image in-place
--convert FORMAT
Convert to specified format (qcow2, raw, vdi, etc.)

CAVEATS

Only use on offline virtual machines to avoid data corruption. Requires sufficient disk space for output image. Original image should be backed up before in-place operation.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community