0

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.

user6356121
  • 17
  • 2
  • 5

1 Answers1

2

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

Community
  • 1
  • 1
piyushj
  • 1,546
  • 5
  • 21
  • 29
  • Thanks very much.I'll have a try as you said. – user6356121 May 20 '16 at 07:05
  • Ran into this after my qcow2 grew by 30 gigs after a few snapshots were made then deleted. It's easily solved by cloning it using `qemu-img convert source.qcow2 output.qcow2` https://www.redhat.com/archives/libvirt-users/2013-April/msg00120.html – Ray Foss Jun 17 '17 at 12:26