Fstrim & Discard on RAW disk

daftlink

Member
Mar 14, 2021
20
0
21
32
Hello
Since I've enabled replication between a remote server and one of my VM I notice a constant increase of storage. In fact, when I discovered it when I reach 100% of my Thin-provisioning capacity on the data pool. So after reading a couple of threads, I found that I need to enable the Discard option and do 'fstrim' command inside the guest.

However, as there's continuous sync, the size increase around 5GB by hour which makes it necessary for me to rerun the command every 4-6 h. Is there a way to automatically free unused storage except with a cron job.
I'm also wondering about the impact on my hardware which is an NVMe and especially about lifespan.

Below VM config:

Code:
boot: order=scsi0
cores: 2
memory: 4096
name: laura
net0: virtio=4E:63:E8:31:F4:5D,bridge=vmbr0
numa: 0
onboot: 1
ostype: l26
scsi0: local-lvm:vm-100-disk-0,size=10G
scsi1: local-lvm:vm-100-disk-1,backup=0,discard=on,size=650G
scsi2: local-lvm:vm-100-disk-2,discard=on,size=11G
scsi3: local-lvm:vm-100-disk-3,size=3G,ssd=1
scsihw: virtio-scsi-pci
smbios1: uuid=8aa2682b-6e4f-4461-ba2f-cba235c78151
sockets: 1
startup: order=1
vmgenid: 64ff41b1-5a4b-4177-94fd-e6800d6cc98c

Below storage.cfg
Code:
dir: local
        path /var/lib/vz
        content backup,iso,vztmpl

lvmthin: local-lvm
        thinpool data
        vgname pve
        content images,rootdir
 
Last edited:
hi,

there should be a systemd timer for that in /lib/systemd/system/fstrim.timer which you can edit