virt-sparsify in Proxmox?

mlanner

Active Member
Apr 1, 2009
186
1
38
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?
 

mlanner

Active Member
Apr 1, 2009
186
1
38
Berkeley, CA
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

manu

Proxmox Staff Member
Mar 3, 2015
806
64
28
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
 

spirit

Famous Member
Apr 2, 2010
4,798
391
103
www.odiso.com
- If you use "move disk" option offline to convert the disk, it'll be sparse (move disk online don't create sparse image)
- you can do a backup/restore
- you can use fstrim inside a vm, if you use virtio-scsi + discard option.
 
  • Like
Reactions: mjw

mlanner

Active Member
Apr 1, 2009
186
1
38
Berkeley, CA
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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!