On Wed, Dec 01, 2021 at 18:35:44 +0100, Elias Mobery wrote:
Hey man, I tried both suggestions, thanks again.
Option 1.) Create/attach a second qcow2 disk & unplug when wiping.
This did not work unfortunately. After wiping the overlay filesystem on the
host (where the snapshots are sitting), I cannot create another snapshot, a
similar error message like before appears.
Okay, that's weird. Could you please post your exact steps?
Additionally if you have a new enough libvirt you can actually possibly
even try using a disk with <transient/>. This transparently creates a
overlay (in the same path as the image though, not sure if it suits your
setup) and automatically discards it when unplugging or shutting down
the VM.
In such case you could simply unplug and replug the disk, but note that
this feature was implemented only this year IIRC, so you need a fairly
recent libvirt to do so.
Option 2.) Enabling Discard
Now I think this worked, but I'm not sure. I read all the docs, and enabled
discard like so on the VM domain:
<driver name='qemu' type='qcow2' discard='unmap'>
This is the correct setting. Unmap means that the qcow2 image should
unmap the blocks which were discarded.
I tried both discard=unmap and discard=on (same thing)
Then I enabled fstrim in the guest like this:
(Not entirely sure if I am missing smth)
sudo fstrim -av
Or permanently
sudo systemctl enable --now fstrim.timer
Yup, both should do fine. Now if you delete something in the VM (which
would result in freeing blocks in the overlay; deleting something from
the base image won't help obviously) the overlay image should shrink.