[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVM - Qcow2 image size behavior

From: Jakob Bohm
Subject: Re: KVM - Qcow2 image size behavior
Date: Wed, 25 Sep 2019 18:59:23 +0200
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 25/09/2019 17:05, Julianno Nogueira wrote:

Hello everyone! I would like to thank you all for the project and the tool developed across these years. I am a fan of yours! This is very important to make the new technology era a better and open place to work and live with!

I´m facing a weird listing image file behaviour (or at least I think It is), that have a 500GB Qcow2 image:

[root@server /]# qemu-img info /var/lib/libvirt/images/netvoltcloudserv.img
image: /var/lib/libvirt/images/netvoltcloudserv.img
file format: qcow2
virtual size: 500G (536870912000 bytes)
disk size: 489G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true

- The Image size is 500GB, and that´s correct and exacly what I have set up.

Now the problem is when I ls this image:

[root@server /]# ls -la /var/lib/libvirt/images/
total 512593892
drwx--x--x.  4 root root            75 Set 16 22:46 .
drwxr-xr-x. 10 root root           117 Jun 20 12:04 ..
drwx--x--x.  2 root root            29 Jul  5  2018 discos_virtuais
-rwx--x--x.  1 qemu qemu *1010408555008* Set 25 11:51 netvoltcloudserv.img
drwx--x--x.  2 root root             6 Set 16 22:46 nsf-pool-1

*- The size of this image is 1TB!*

*So my question based on this, is: *

- Is this a "bug" or "expected" behavior?
- Who to "fix the size" or make SISOP see it correctly (with 500GB)?

SYSOP should know that most modern file systems (including the one containing
your/var/lib/libvirt/images/ directory) support the feature known as "sparse
files", wheresome parts of a file are not actually stored, but are treated
as all zeroes when read. On unix/linux the true disk use can be seen with
the standard utility "du" .  On Windows, the resource kit tool diruse can
usually show this info.

In your case qemu itself claims the file only uses 489G of disk space, but I
don'tknow if that corresponds to the reality as reported by the command

du -ha /var/lib/libvirt/images/

As for qcow2 specifically, the format allows some qcow2 clusters (each 64K in
yourimage) to be such sparse clusters, and this is often the default when
creating newqcow2 image files.

Finally note that the virtual disk size seen by your virtual machine (in this
case500GB) may be less or more than the apparent size and actual disk use of
the qcow2 file.

A qcow2 file contains at least the following: The non-zero clusters from the
virtual disk,snapshots of that image created via the libvirt snapshot
commands, copies ofthe virtual machine ram (if included in snapshots of a
running machine), andmetadata to keep track of where all this is in the
qcow2 file.


Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

reply via email to

[Prev in Thread] Current Thread [Next in Thread]