I got hit with a “phantom” low-space warning in a couple of VMs, where the occupied space in the LV is much higher than the one in the filesystem,
After some looking, it seems that for some reason the filesystem trimming is not working, and deleted space in the filesystem is not being reclaimed for the thin-provisioned LV.
The recommended was to solve this was to run “fstrim /rw” inside the VM, but I found that while this trims the filesystem, the space is not reclaimed in the LV. If I try to trim again, I get the same amount of space trimmed every time I boot up the VM.
I tried trimming from dom0, to see if that made a difference, and it does not. Every time the filesystem is mounted again, the supposedly trimmed space is trimmed again! Like this:
[@dom0 ~]$ sudo mount /dev/qubes_dom0/vm-vmname-private /mnt
[@dom0 ~]$ sudo fstrim -v /mnt
/mnt: 371 MiB (388997120 bytes) trimmed
[@dom0 ~]$ sudo umount /mnt
[@dom0 ~]$ sudo mount /dev/qubes_dom0/vm-vmname-private /mnt
[@dom0 ~]$ sudo fstrim -v /mnt
/mnt: 371 MiB (388997120 bytes) trimmed
[@dom0 ~]$ sudo umount /mnt
(this could be repeated ad infinitum with no change).
I checked with lsblk -D, and all devices above the LV seem to have discards enabled
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
└─nvme0n1pX 0 512B 2T 0
└─luks-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 0 512B 2T 0
├─qubes_dom0-vm--pool_tmeta 0 512B 2T 0
│ └─qubes_dom0-vm--pool-tpool 0 512B 2T 0
│ ├─qubes_dom0-vm--vmname--private 0 2M 2G 0
I also enabled discards in /etc/lvm.conf in dom0 (although that should not affect this, based on what I read).
Nevertheless, the filesystems seem to never get trimmed, and this leads to VMs starting to run out of space. I must be missing something within LVM, but I can’t figure out what. Any help will be much appreciated!
Thanks!!