Technical

qcow2 file is bigger as hdd config: why and how to shrink it

qcow2 file is bigger as hdd config: why and how to shrink it

Your qcow2 file is bigger as hdd config shows, and that’s normal — mostly. The file on disk can be larger than the virtual disk size you set, thanks to preallocation, snapshots, and metadata. Here’s how to see what’s really going on and shrink it back down.

Detailed view of a SATA power cable connector with colorful wiring.

Why the file is bigger

qcow2 is a sparse format, but it’s not always thin. If you created the disk with preallocation=metadata or preallocation=full, Proxmox writes out the full size immediately. Snapshots also add delta files, and each one carries overhead. Plus the qcow2 header itself takes a few hundred KB.

Check the actual usage with qemu-img info. You’ll see two numbers: virtual size (what the guest thinks it has) and disk size (what the file actually uses on the host). If disk size is bigger than virtual size, you’ve got preallocation or snapshot bloat.

How to check

qemu-img info /var/lib/vz/images/100/vm-100-disk-0.qcow2

Look for disk size and virtual size. If disk size is larger, something’s taking up space beyond the guest’s data.

Seagate Cheetah 15K.5 SCSI hard drive with metal casing, advanced technology for data storage.

How to shrink it

First, delete any snapshots you don’t need. Each snapshot is a separate qcow2 file that references the base, and they pile up. In Proxmox, go to the VM’s Snapshots tab and remove old ones.

Then, if the disk is still bloated, you can compact it. Shut down the VM and run:

qemu-img convert -O qcow2 vm-100-disk-0.qcow2 vm-100-disk-0.compacted.qcow2

Then replace the original with the compacted file. This rewrites the image without preallocation and drops any unused space. Make sure you have enough free space for the new file first.

If you’d rather not mess with command line, there’s a simpler way: move the disk to another storage and back. Proxmox will reallocate it as thin by default. Just go to the VM’s Hardware tab, select the disk, and use Move disk. Pick a different storage, then move it back. That often fixes the bloat without touching the terminal.

My take

Don’t obsess over a few hundred MB of overhead. But if your qcow2 file is double the configured size, it’s worth cleaning up. Snapshots are usually the culprit — people forget they exist until the disk fills up. And if you’re backing up to NFS, a bloated qcow2 makes backups slower too, like this NFS backup issue shows.

Leave a comment

Comments are reviewed before they appear. Your email is never published.