snapshots are stored inside the qcow2 harddisk file of the vm, which is good in terms of “simple”, just one file, where in virtualbox there is the disk.vdi and snapshots are stored in a separate folder as separate files.

when kvm snapshots are deleted however, the disk size of the qcow2 stays unchanged.

so how to consolidate those snapshots and reclaim the space?

same as virtualbox:

  1. clone vm (disk image)
  2. delete old vm (disk image)
  3. rename the new-clone (disk image) to the old (disk image name)

no kidding.

there is a tool called virt-sparsify

hostnamectl; # tested with
  Operating System: Debian GNU/Linux 11 (bullseye)
            Kernel: Linux 5.10.0-21-amd64
      Architecture: x86-64

# warning! major modification of host system
apt update
apt install libguestfs-tools

# along with those
virt-admin               virt-copy-out            virt-format              virt-list-partitions     virt-p2v-make-kiwi       virt-sysprep             virt-xml
virt-alignment-scan      virt-customize           virt-get-kernel          virt-log                 virt-pki-validate        virt-tail                virt-xml-validate
virt-builder             virt-df                  virt-host-validate       virt-ls                  virt-qemu-run            virt-tar                 
virt-builder-repository  virt-dib                 virt-index-validate      virt-make-fs             virt-rescue              virt-tar-in              
virt-cat                 virt-diff                virt-inspector           virt-manager             virt-resize              virt-tar-out             
virt-clone               virt-edit                virt-install             virt-p2v-make-disk       virt-sparsify            virt-viewer              
virt-copy-in             virt-filesystems         virt-list-filesystems    virt-p2v-make-kickstart  virt-ssh-helper          virt-win-reg          

but it does that in an awfull complicated way “filling with zeros” takes ages.

being big fan of clean and simple solutions the clone and delete old is the simple solution in this case.

even this process could be simplified, by a simple button in virt-manager that says “consolidate disk space”.

or by a virt-consolidate command that is part of virt-manager’s standard repository.

life will find it’s way…

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin