[virt-tools-list] Storage image files and permissions

Vincenzo Romano vincenzo.romano at notorand.it
Wed Nov 28 14:14:59 UTC 2018


Il giorno mer 28 nov 2018 alle ore 15:10 Daniel P. Berrangé
<berrange at redhat.com> ha scritto:
>
> On Wed, Nov 28, 2018 at 03:05:29PM +0100, Vincenzo Romano wrote:
> > Il giorno mer 28 nov 2018 alle ore 14:41 Eric Blake
> > > > I doesn't make any real difference. It just puzzles me.
> > >
> > > The difference is whether you choose to preallocate an image. There are
> > > performance tradeoffs for doing so (a preallocated image is faster than
> > > a sparse one when it comes to writing to previously unused portions of
> > > the disk, but occupies more host space as a result - also, a
> > > preallocated image tends to have less fragmentation and less chance of
> > > hitting ENOSPC).
> >
> > Yes, but I've never seen (so far) a sparse QCOW file. After all, QCOW
> > was introduced also to let users
> > use file systems not supporting "sparse files".
>
> qcow2 files can be sparse if you request it to preallocate metadata
> only:
>
> No preallocation -> small file size, small  allocation size:
>
>   $ qemu-img create -f qcow2 demo.qcow2 1G
>   Formatting 'demo.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
>   $ ls -alhs demo.qcow2
>   196K -rw-r--r--. 1 berrange berrange 193K Nov 28 14:07 demo.qcow2
>
> Metadata prealloc -> full file size, small allocation size (ie sparse)
>
>   $ qemu-img create -f qcow2 -o preallocation=metadata demo.qcow2 1G
>   Formatting 'demo.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
>   $ ls -alhs demo.qcow2
>   328K -rw-r--r--. 1 berrange berrange 1.1G Nov 28 14:07 demo.qcow2
>
> Full preallocate -> full file size, full allocation size:
>
>   $ qemu-img create -f qcow2 -o preallocation=full demo.qcow2 1G
>   Formatting 'demo.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
>   $ ls -alhs demo.qcow2
>   1.1G -rw-r--r--. 1 berrange berrange 1.1G Nov 28 14:08 demo.qcow2
>
>
> qcow2 files also become sparse if you have support for discard and the
> guest OS trims data blocks.


I think the documentation
(https://qemu.weilnetz.de/doc/qemu-doc.html#qemu_005fimg_005finvocation)
needs some improvement.

Great explanation, though: thanks a lot!

-- 
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS




More information about the virt-tools-list mailing list