Sun, December 28, 2025 ยท 1 min read

Virt-sparsify

Virt-sparsify

While doing virsh migrate on VM (same subnet), I have run into situation where the destination disk copied is larger than the source.

Example:

  • Disk size 20G qcow2
  • Source VM1: disk used 10G
  • After migration to another host size of VM disk shows as 20G

This was also seen when I had to just do a backup/create custom qcow2 images for my eve-ng labs.

For virsh migrate --sparse option can be used while migrating live VMs.

If the VM disks were copied over scp, rsync we can use virt-sparsify to reclaim unused disk space.

root@eve-lab:~# du -sch rhel8.10-2025-12-29.qcow2
23G rhel8.10-2025-12-29.qcow2
23G total

root@eve-lab:~# qemu-img info rhel8.10-2025-12-29.qcow2
image: rhel8.10-2025-12-29.qcow2
file format: qcow2
virtual size: 22 GiB (23622320128 bytes)
disk size: 22 GiB
cluster_size: 65536
cleanly shut down: no
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: true
    refcount bits: 16
    corrupt: false
    extended l2: false

Run virt-sparsify:

root@eve-lab:~# virt-sparsify rhel8.10-2025-12-29.qcow2 rhel8-sparse.qcow2

Verify result:

root@eve-lab:~# du -sch rhel8.10-2025-12-29.qcow2
23G rhel8.10-2025-12-29.qcow2
23G total