-
Pl
chevron_right
Reducing (sparsifying) qcow2 image of Windows10
pubsub.slavino.sk / planetdebian · Thursday, 2 September, 2021 - 03:17
Since joining Fujitsu I am permanently running a VM (kvm/qemu) with Windows 10 (unfortunately necessary). While the usaged disk space is about 50G, the actual qcow2 file had grown to over 180G, not good.
Searching the web the very promising
virt-sparsify
is mentioned again and again, and the man page gives hope, but as it turns out it is broken and calls
qemu-img
with incorrect/not-working arguments (see
this bug
).
Another problem seems to be that by default the
discard mode
seems not to be set to
unmap
.
So here are the stages how I reduced the size of the qcow2 image back down to around 60G.
- Turn off the VM
-
Make sure you are using VirtIO for the disk, select
Discard mode: unmap
-
Boot into Windows, and from an elevated prompt run:
Optimize-Volume -DriveLetter C -ReTrim -Verbose
- Shut down the VM
-
Run a dummy conversion which sparsifies the image:
qemu-img convert -O qcow2 orig.qcow2 sparse.qcow2
- Rename/Backup the images and boot back into Windows.
That helped in my case, without any consequences (till now) for the Windows installation.
Značky: #Debian