Hi,

I have a QEMU / KVM VM running Windows that has been running as a guest
on various Debian hosts for about a decade. The Windows OS has
undergone various repairs and reinstalls over the years. I was recently
quite surprised to discover that the VM image size (actual size on
disk, not apparent size) has somehow grown to about 4x the allocated
size of the disk:

~# ls -alsh /var/lib/libvirt/images/win10.qcow2 
314G -rw------- 1 root root 352G May 15 12:40 
/var/lib/libvirt/images/win10.qcow2

~# qemu-img  info /var/lib/libvirt/images/win10.qcow2
image: /var/lib/libvirt/images/win10.qcow2
file format: qcow2
virtual size: 80 GiB (85899345920 bytes)
disk size: 314 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: true
    refcount bits: 16
    corrupt: false
    extended l2: false
Child node '/file':
    filename: /var/lib/libvirt/images/win10.qcow2
    protocol type: file
    file length: 352 GiB (377549750272 bytes)
    disk size: 314 GiB

I've found all kinds of discussions of this type of thing online, but
no explanation / solution that seems applicable to my situation.

The image contains no snapshots:

~# qemu-img snapshot -l /var/lib/libvirt/images/win10.qcow2
~# 

I think TRIM / DISCARD is properly configured. From the VM XML:

<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' discard='unmap'/>
      <source file='/var/lib/libvirt/images/win10.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' 
function='0x0'/>
</disk>

TRIM / DISCARD is enabled in the Windows guest, and I've issued manual
TRIM commands in the guest several times, like so:

https://winaero.com/trim-ssd-windows-10/

I think this did claw back some space, but only on the order of tens of GB.

Can anyone explain what's going on here, and how I can fix this?

-- 
Celejar

Reply via email to