virt-sparsify in Proxmox?

mlanner

Renowned Member
Apr 1, 2009
190
1
83
Berkeley, CA
I have a need to maintain a VM in Proxmox as a template that gets shipped as a .qcow2 or .vmdk disk. However, before shipping it, I'd like to make it as small as possible. During installation of software inside the VM I download fairly large files, which then add a lot of "used" space in the image. I've read about 'virt-sparsify' being a good tool to "trim" down the image size. Does anyone a) have any experience with virt-sparsify, and b) it's not in the Debian repos -- so is there a plan to include it with Proxmox?
 
I think I found the answer to my own question. It looks like the 'virt-sparsify' is part of the 'libguestfs-tools' package. My only concern now is if it will conflict with any Proxmox package. Hopefully it won't. I'll try to install it on a PVE test host and report back here once I've got that going have done some testing.
 
  • Like
Reactions: mjw
You could use zerofree available in the debian archive to fill the unused block of the partitions with 0. I have not tested yet on Qcow2 disk images, but with vmdk it makes a huge win to reduce the disk size.

Zerodisk requires you to be in single user mode.
You can also try the following scripted approach, whihc works in multi user setups:
https://anonscm.debian.org/cgit/clo...packer-virtualbox-vagrant/scripts/minimize.sh
 
I found that the libfsguest-tools had too many missing dependencies.

Thanks for all the ideas. I'm going to automate the build by running a backup of the image and then restoring it to another VMID. Seems to be the simplest option at this point.