[libvirt-users] virt-sparsify changing the apparent-size of files

libvirt_users at skagitattic.com libvirt_users at skagitattic.com
Thu Jun 23 17:07:45 UTC 2016


On Thu, 23 Jun 2016 17:57:53 +0100
"Richard W.M. Jones" <rjones at redhat.com> wrote:

> On Thu, Jun 23, 2016 at 10:57:43AM -0500,
> libvirt_users at skagitattic.com wrote:
> > Thanks for all the information, I think my last remaining question
> > is why the image created with virt-install shows the full apparent
> > size and the image from virt-sparsify does not?  (The image
> > testimage1.qcow2 created with default options).  
> 
> I don't really know what you mean by "full apparent size".  If you are
> talking about the output of "ls -l", then don't -- that number is
> unrelated to the virtual size or the space consumed on disk.  Always
> use "qemu-img info".

So I think I figured out what's different.  If I do
preallocation=metadata I end up with the apparent size the same as the
initial install.

    # virt-sparsify testimage.qcow2 testimage3.qcow2 --tmp /bigtmp -o
    preallocation=metadata Input disk virtual size = 53687091200 bytes
    (50.0G) Create overlay file in /bigtmp to protect source disk ...
    Examine source disk ...
    Fill free space in /dev/sda1 with zero ...
     100%
    00:00 Clearing Linux swap on /dev/sda5 ... Copy to destination and
  make sparse ...

    Sparsify operation completed with no errors.  Before deleting the
    old disk, carefully check that the target disk boots and works
    correctly.

    # ls -lsh testimage.qcow2 testimage1.qcow2 testimage3.qcow2 
    1.1G -rw-r--r-- 1 root root 1.1G Jun 22 22:41 testimage1.qcow2
    1.1G -rw-r--r-- 1 root root  51G Jun 23 16:20 testimage3.qcow2
    2.5G -rw-r--r-- 1 root root  51G Jun 22 20:22 testimage.qcow2


I don't know how to tell what the image's pre-allocated state is other
then checking for apparent size as "qemu-img info" does not see a
difference (other then the fact I played around with snapshotting on
the testimage1).

    # qemu-img info testimage1.qcow2
    image: testimage1.qcow2
    file format: qcow2
    virtual size: 50G (53687091200 bytes)
    disk size: 1.1G
    cluster_size: 65536
    Snapshot list:
    ID        TAG                 VM SIZE                DATE       VM
     CLOCK 1         test                      0 2016-06-22 22:41:44
     00:00:00.000 Format specific information:
        compat: 1.1
        lazy refcounts: false
    # qemu-img info
    testimage3.qcow2 image: testimage3.qcow2
    file format: qcow2
    virtual size: 50G (53687091200 bytes)
     disk size: 1.0G
    cluster_size: 65536
    Format specific information:
         compat: 1.1
         lazy refcounts: false


I will read up some more on preallocation though and hopefully find all
the answers I need.

Thanks for your help looking at this,

Keelan

 
> Rich.
> 




More information about the libvirt-users mailing list