Is there any way to shrink qcow2 image without converting it raw?
I cannot convert it to raw because I don't have disk space enough for raw image.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Noop conversion (qcow2-to-qcow2) removes sparse space:
qemu-img convert -O qcow2 source.qcow2 shrunk.qcow2
You can also try add compression (
-c) to the output image:
qemu-img convert -c -O qcow2 source.qcow2 shrunk.qcow2
Before running above command be sure to shutdown the VM. After you are satisfied with the result, you can rename shrunk.qcow2 to original name your VM config wants.
virt-sparsify - it will zerofill the unused blocks in the image and then deduplicate the zeroes.