trim container filesystem on lvm-thin

michabbs

Well-Known Member
May 5, 2020
138
20
58
What is the "correct" way to automatically trim filesystems residing in lvm-thin pool?

I can see there is "pct fstrim" command and I can run it manually (and it works!), but... it seems strange that such important functionality have to be done manually. Is there any "standard way" of doing it automatically? Or should i simply put it to cron and forget?
 
Hi,

i put it in a cron job which is executed once a week, works great so far.

Bash:
#!/bin/bash
PCT=/usr/sbin/pct
for i in $($PCT list | grep running | awk '/^[0-9]/ {print $1}'); do
  $PCT fstrim $i
done
 
Last edited:
  • Like
Reactions: michabbs