The image will not shrink automatically, since when you delete files, you don’t actually delete data (this is why undelete works). Qemu has a facility to shrink qcow2 images back, but what the utility does is really deduplicate the zeroes from the disk, leaving all other information intact. So the idea would be to:
- Zero-fill the drive (
dd if=/dev/zero of=/some/fileuntil you run out of space) - delete /some/file
- shut down the VM
- cd to where the images for the VM are kept and run
qemu-img convert -O qcow2 original_image.qcow2 deduplicated_image.qcow2 - change the VM settings to use the new deduplicated_image.qcow2, test the VM is working, and remove the old image
This, afaik, will only work with qcow2 images, I haven’t tested other formats.