me,apporc
2013-Apr-12 09:25 UTC
[libvirt-users] after snapshot-delete, the qcow2 image file size doesn't decrease
After snapshot-delete, the qcow2 image file size doesn't decrease, isn't
that a waste of disk space?
Would someone please tell me how to decrease the file size when
snapshot-delete, if that's possible?
The image file name of my virtual machine is d0.qcow
As follows:
[root at test1 ]# virsh list
Id Name State
----------------------------------------------------
32 bfbe8ca8-8579-11e2-844a-001018951f48 running
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 3.6G
cluster_size: 65536
[root at test1 ]# ls -lh
total 3.6G
-rw------- 1 qemu qemu 3.6G Apr 12 17:13 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-list bfbe8ca8-8579-11e2-844a-001018951f48
Name Creation Time State
------------------------------------------------------------
[root at test1 8]# virsh snapshot-create bfbe8ca8-8579-11e2-844a-001018951f48
Domain snapshot 1365758005 created
[root at test1 ]# virsh snapshot-create bfbe8ca8-8579-11e2-844a-001018951f48
Domain snapshot 1365758022 created
[root at test1 bfbe8ca8-8579-11e2-844a-001018951f48]# virsh snapshot-list
bfbe8ca8-8579-11e2-844a-001018951f48
Name Creation Time State
------------------------------------------------------------
1365758005 2013-04-12 17:13:25 +0800 running
1365758022 2013-04-12 17:13:42 +0800 running
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 3.8G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 1365758005 127M 2013-04-12 17:13:25 00:00:53.141
2 1365758022 127M 2013-04-12 17:13:42 00:01:09.508
[root at test1 ]# ls -lh
total 3.9G
-rw------- 1 qemu qemu 3.9G Apr 12 17:14 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-delete
bfbe8ca8-8579-11e2-844a-001018951f48 1365758022
Domain snapshot 1365758022 deleted
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 3.8G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
0 1970-01-01 08:00:00 00:00:00.000
[root at test1 ]# ls -lh
total 3.9G
-rw------- 1 qemu qemu 3.9G Apr 12 17:14 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-delete
bfbe8ca8-8579-11e2-844a-001018951f48 1365758005
Domain snapshot 1365758005 deleted
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 3.8G
cluster_size: 65536
[root at test1 ]# ls -lh
total 3.9G
-rw------- 1 qemu qemu 3.9G Apr 12 17:14 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-create bfbe8ca8-8579-11e2-844a-001018951f48
Domain snapshot 1365758311 created
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 3.8G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 1365758311 252M 2013-04-12 17:18:32 00:05:58.136
[root at test1 ]# ls -lh
total 3.9G
-rw------- 1 qemu qemu 3.9G Apr 12 17:18 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-create bfbe8ca8-8579-11e2-844a-001018951f48
Domain snapshot 1365758338 created
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 4.1G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 1365758311 252M 2013-04-12 17:18:32 00:05:58.136
2 1365758338 252M 2013-04-12 17:18:58 00:06:24.272
[root at test1 ]# ls -lh
total 4.1G
-rw------- 1 qemu qemu 4.1G Apr 12 17:19 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-list bfbe8ca8-8579-11e2-844a-001018951f48
Name Creation Time State
------------------------------------------------------------
1365758311 2013-04-12 17:18:31 +0800 running
1365758338 2013-04-12 17:18:58 +0800 running
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 4.1G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 1365758311 252M 2013-04-12 17:18:32 00:05:58.136
2 1365758338 252M 2013-04-12 17:18:58 00:06:24.272
[root at test1 ]# virsh snapshot-delete
bfbe8ca8-8579-11e2-844a-001018951f48 1365758338
Domain snapshot 1365758338 deleted
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 4.1G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 1365758311 252M 2013-04-12 17:18:32 00:05:58.136
[root at test1 ]# ls -lh
total 4.1G
-rw------- 1 qemu qemu 4.1G Apr 12 17:20 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-delete
bfbe8ca8-8579-11e2-844a-001018951f48 1365758311
Domain snapshot 1365758311 deleted
[root at test1 ]# qemu-img info d0.qcow
image: d0.qcow
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 4.1G
cluster_size: 65536
[root at test1 ]# ls -lh
total 4.1G
-rw------- 1 qemu qemu 4.1G Apr 12 17:20 d0.qcow
drwx------ 2 root root 4.0K Apr 12 17:12 held
[root at test1 ]# virsh snapshot-list bfbe8ca8-8579-11e2-844a-001018951f48
Name Creation Time State
------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://listman.redhat.com/archives/libvirt-users/attachments/20130412/922bf06d/attachment.htm>
Daniel P. Berrange
2013-Apr-12 09:53 UTC
[libvirt-users] after snapshot-delete, the qcow2 image file size doesn't decrease
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. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|