问题描述
大家好!我正在学习OpenStack,qemu和kvm.
Hello everyone!I am learning OpenStack、qemu and kvm.
我们知道,QCOW2是kvm虚拟机的磁盘文件格式. 我发现了一种现象,那就是QCOW2磁盘文件的大小迅速增长.我创建了一个使用QCOW2磁盘文件和win7操作系统的kvm虚拟机.我没有为此做任何动作. 但是一天后,其QCOW2磁盘文件的大小增加了1G以上.
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.
我知道关闭操作系统的自动更新会减慢QCOW2磁盘文件大小的增长.你能告诉我你还有其他更有效的方法吗?如果能得到您的帮助,我们将不胜感激.
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.
推荐答案
qcow将增长到指定的大小,并且仅对以前未触及的块进行新写入.如果您的来宾正在快速删除和写入文件,它将迅速填满该空间,而来宾仍然会显示大量未使用的空间,这仅仅是因为您还删除了文件.
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.
您可以对qcow2文件进行重复数据删除,只需在Windows上使用sdelete
或在Linux上使用dd if=/dev/zero of=/some/path/to/file
对其进行零填充,然后删除零文件并在该文件上运行qemu-img convert
-qemu-img将创建一个新文件没有零填充的方块.
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.
有关更多信息,请参见 https://serverfault.com/questions/547374/qcow2-叠加得太快了
For more information look at https://serverfault.com/questions/547374/qcow2-overlay-growing-too-rapidly
这篇关于qcow2磁盘文件的大小快速增长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!