Should I turn on zfs-trim on my pools or should I trim on a schedule using systemd timers or cron?
Solution 1:
From the ZoL git commit message adding trim support:
In addition to the manual
zpool trim
command, a background automatic TRIM was added and is controlled by the 'autotrim' property. ...Since the automatic TRIM will skip ranges it considers too small there is value in occasionally running a full
zpool trim
. This may occur when the freed blocks are small and not enough time was allowed to aggregate them. An automatic TRIM and a manualzpool trim
may be run concurrently, in which case the automatic TRIM will yield to the manual TRIM.
so zpool set autotrim=on
and a periodic zpool trim
is the recommended approach.
I'd suggest a cron job (or systemd timer if you prefer) to run zpool trim
at the same frequency as you run scrub your pool, which is set as the second Sunday of every month by default (have a look at /etc/cron.d/zfsutils-linux
), but on different days of the month so the two aren't running simultaneously.