[virt-tools-list] Enabling qcow2 compression with virt-install

Richard W.M. Jones rjones at redhat.com
Sat Aug 25 07:33:49 UTC 2012


On Fri, Aug 24, 2012 at 09:35:01PM +0100, Paul Maunders wrote:
> >> Is it possible to enable qcow2 compression when using virt-install to
> >> create a new image as part of a new virtual machine?
> >>
> >> I've searched the manual and online, but can't find any info on this.
> >
> > IIRC if you create the target disk yourself (using 'qemu-img create')
> > and point virt-install at the disk (--disk path=foo.qcow2,format=qcow2)
> > then it should work.
> >
> > Rich.
> 
> I gave it a go, but it doesn't look like the compression option is
> supported with qemu-img create.
>
> It is supported with qemu-img convert, so I tried creating an empty
> image, then converting this to be a compressed image. However, when I
> installed an OS on to this image no files were compressed.

Right.  qemu doesn't support compression on writes, so you can't
create a new disk (with no content) with compression enabled.  You can
only convert an existing disk with content, and I believe writes to
such a disk are either entirely disabled or create uncompressed
content.

> I was able to get some compression working by installing a virtual
> machine without compression using virt-install, stopping it, using
> qemu convert -c ... to compress the image to a new image, then moving
> the new image into the original location.
> 
> 370M Aug 24 21:00 test-centos-compressed.img
> 1.3G Aug 24 20:17 test-centos-uncompressed.img
> 
> However, although the existing data was compressed, it seems that when
> I started the vm, any new data appears to be stored uncompressed. I
> tested this by downloading a large gzip'd wikipedia xml dump inside
> the vm, and uncompressing it.

See above.

virt-sparsify is another option if you're just trying to create
small (offline) disk images.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora




More information about the virt-tools-list mailing list