From: Paolo Bonzini <pbonzini@redhat.com>
To: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Using TRIM to shrink qcow2 images
Date: Thu, 08 Aug 2013 14:00:15 +0200 [thread overview]
Message-ID: <5203884F.5040805@redhat.com> (raw)
In-Reply-To: <5203744F.4010407@ramses-pyramidenbau.de>
On 08/08/2013 12:34 PM, Ralf Ramsauer wrote:
> Hi,
>
> QCOW2 uses a similar idea like file holes (sparse files) on filesystems [1].
> RAW Images also may use file holes.
>
> If qemu would support TRIM, then the guest could easily discard and zero
> all unused blocks.
QEMU supports trim. 1.5 supports it with raw images only, 1.6 will add
qcow2 support. Because it has the potential to cause fragmentation, it
needs to be enabled explicitly. Just add "discard=on" to the -drive option:
qemu-system-x86_64 -enable-kvm -m 2048 ...\
-drive if=virtio,discard=on,file=$HOME/foo.qcow2
It's probably always a good idea if the image is a block device on an
SSD, but not necessarily on an image that is backed (for example) by a
file or by a thin-provisioned logical volume.
> The host system could detect all unused blocks in a (e.g.) qcow2 image
> and shrink it down to its minimum size.
This depends on the host support for discard (on block device-backed
qcow2 images) or hole punching (for file-backed qcow2 images). For
files, running fstrim in the guest will shrink down the on-disk
footprint of a qcow2 image.
Paolo
> Did anyone already think about that?
>
> [1] : https://people.gnome.org/~markmc/qcow-image-format.html
>
> Regards,
>
next prev parent reply other threads:[~2013-08-08 12:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-08 10:34 [Qemu-devel] Using TRIM to shrink qcow2 images Ralf Ramsauer
2013-08-08 11:47 ` François Revol
2013-08-08 12:00 ` Paolo Bonzini [this message]
2013-10-04 6:22 ` Alexey Kardashevskiy
2013-10-04 7:05 ` Paolo Bonzini
2013-10-04 7:07 ` Alexey Kardashevskiy
2013-10-04 12:45 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5203884F.5040805@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=ralf@ramses-pyramidenbau.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).