[libvirt-users] after snapshot-delete, the qcow2 image file size doesn't decrease

Eric Blake eblake at redhat.com
Mon Apr 15 15:54:12 UTC 2013


On 04/12/2013 03:53 AM, Daniel P. Berrange wrote:
> On Fri, Apr 12, 2013 at 05:25:23PM +0800, me,apporc wrote:
>> After snapshot-delete, the qcow2 image file size doesn't decrease, isn't
>> that a waste of disk space?
> 
> Yes, but that's life. When deleting an internal qcow2 snapshot,
> QEMU will just mark the clusters as unused, it won't return them
> to the underlying filesystem. These unused clusters will, however,
> be re-used if the qcow2 file needs to grow later.
> 
>> Would someone please tell me how to decrease the file size when
>> snapshot-delete, if that's possible?
> 
> You can't do it in place. The only option would be to use qemu-img
> to clone the qcow2 file to a new qcow2 file & delete the original.

Check out 'virt-sparsify' from libguestfs-tools, which is designed to
help you minimize disk space (including this trick of copying from one
qcow2 to another to reduce space occupied by now-unused clusters).

Meanwhile, if you are really ambitious, write a patch to upstream qemu
that can do a defrag pass on an existing qcow2 image, and expose it
through both qemu-img (for manipulating offline disks) and a QMP monitor
command (so that we can request an online defrag without any noticeable
guest downtime).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20130415/de0860af/attachment.sig>


More information about the libvirt-users mailing list