Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
the -c flag in qemu-img convert -c -O is for compression, not shrink... and it can decrease the disk speed... – Anton Anikin Jul 4 '14 at 14:41

try virt-sparcify - it will zerofill the unused blocks in the image and then deduplicate the zeroes

share|improve this answer
Thanks for you answer, but virt-sparcify said it cannot resize disk images and I found virt-resize from that, but looks like I still need to allocate spaces to expand (that I don't have enough spaces on my harddisk). Anyway, Thank you very much for you info. – YOU Sep 27 '12 at 8:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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