2

I use qcow2 file format and create snapshots using a Virt-manager GUI. I assume I have 100GB disk space and 70% is used by VM at this moment. The qcow2-file size is about 70GB. I create a snapshot. It is stored inside the qcow2-file, we know. After some days the qcow2-file size is rised up to 120GB. OK, we understand, why. I delete this snapshot, but the qcow2-file size does not change!

"qemu-img info" does not show me any snapshots for this qcow2-file! How to see, what's inside this file and how to clean it up?

I've used "qemu-img convert" but I have a feeling inside that it's not the rigth way to decrease the file size.

1

In order to shrink the image, I'd suggest to use virt-sparsify

export TMPDIR=/var/tmp/
virt-sparsify --check-tmpdir=continue <name>.qcow2 <name>_sparsed.qcow2

Make sure you have enough space in the TMPDIR, otherwise the conversion would crash.

Don't use virt-sparsify on running VM images. You may end up with corrupted image! (see man)


Then you can also use compress option (-c) of the qemu-img convert. However that would probably have some impact on the performance, but probably only during startup and initial load of services.

  • Should I run virt-sparsify only when the VM's state is off? – Igor Schaefer Nov 10 '17 at 9:40
  • @IgorSchaefer Yes, it's required. Otherwise the disk image could be corrupted! – Jaroslav Kucera Nov 10 '17 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.