Qemu-img convert burning CPU for nothing

qemu

I'm trying to reduce the usage of a qcow2 image. I did the following:

qemu-img convert -p -f qcow2 -O qcow2 my_img.qcow2.backup my_img.qcow2

I outputs 200192 bytes and progress is stuck at 0.00%. CPU usage is pegged at 100% and I let it go for 2 hours. The input image file is 160G. Also, iotop says that there's no disk usage. What could qemu-img possibly be doing that's wasting this much time?

Also, I should mention, I've tried using raw output format and it does the same thing.

Best Answer

I had the very same probem with a 149G (virtual 168G) QCOW2 file. The conversion took two days while being stuck at 0.00% for the first day. It was just being very slow.

$ qemu-img check old-fragmented.qcow2 
No errors were found on the image.
2446873/2745536 = 89.12% allocated, 27.96% fragmented, 0.00% compressed clusters
Image end offset: 160389464064

Subsequent conversions with zero fragmentation was as fast as can be expected. Try -o preallocation=metadata for improved performance.

Related Question