Re: Easy way to track Qcow2 space consumption

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

 



On Tue, Oct 08, 2019 at 08:01:11PM +0200, freebsd@xxxxxxxx wrote:
> Hello List,
> 
> I'm using a fairly old KVM version
> 
> ii  pve-qemu-kvm                          2.2-28
> amd64        Full virtualization on x86 hardware
> 
> don't see much point upgrading either since everything works but I could
> still use a feature to keep track of the actual space used by the VMs
> without SSHing into all of them and doing a df -h.
> 
> The VM images (especially the DBs with high rw operation will just grow and
> grow with time), for this to free up space the standard process was:
> 
> 1, Zero-fill the drive (dd if=/dev/zero of=/some/file until you run out of
> space)
> 1B, sdelete -z c: < windows VM
> 2, Shut down the VM
> 3, cd to where the images for the VM are kept and run qemu-img convert -O
> qcow2 original_image.qcow2 deduplicated_image.qcow2
> 
> I wonder if there were any improvements done in the KVM for addressing this
> space issue. A lot of us using qcow2 because it's easier to backup due to
> the small size (eg: a basic configured webserver might only uses 3-4 Gb vs a
> 40GB preallocated empty image full of 0s).

Hi,
I'm CCing the QEMU mailing list and Kevin Wolf, the qcow2 maintainer.

QEMU and qcow2 have support for the discard/trim command that allows the
guest to report unused regions of the disk.  virtio-scsi and recent
virtio-blk devices support this feature.

Set the -drive discard=unmap QEMU command-line option in order to enable
discard.

Run the fstrim(8) Linux command inside the guest.  Other operating
systems may have equivalent commands.

You should find that the qcow2 file has fewer allocated blocks after
this operation.  Consider this an efficient replacement for zero filling
the device.  It is still necessary to shutdown the VM and use qemu-img
convert unless you want to switch to a fancier online backup process
using block job commands.

Stefan

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux