the size of qcow2 disk file grows rapidly

2019-09-05 03:05发布

问题:

Hello everyone!I am learning OpenStack、qemu and kvm.

As we know, QCOW2 is a disk file format of kvm virtual machine. I found a phenomenon, that is the size of QCOW2 disk file grows rapidly. I created a kvm virtual machine which used QCOW2 disk file and win7 operating system. I didn't do any action for it. But a day later, the size of its QCOW2 disk file was increased by more than 1G.

I know that shutting down the operating system's automatically updates will slow the growth of the QCOW2 disk file size. Can you tell me whether you have other more effective ways? I would be appreciated if I can get your help.

回答1:

qcow will grow up to the size specified, and only with new writes to previously untouched blocks. If your guest is deleting and writing files rapidly, it will fill that space out quickly, while the guest will still show plenty of unused space, simply because you also delete files.

You can deduplicate the qcow2 file, simply zero-fill it using sdelete on windows or dd if=/dev/zero of=/some/path/to/file on linux, then delete the zero file and run qemu-img convert on the file - qemu-img will create a new file without the zero filled blocks.

For more information look at https://serverfault.com/questions/547374/qcow2-overlay-growing-too-rapidly