I run Ubuntu 19.10 installed on ZFS through the new ZFS install option on 19.10. This is on a Thinkpad X1 Carbon 7th which is in heavy daily use. No dualboot so it's Ubuntu all the time. The laptop has a SSD, and as I understand it fstrim doesn't read and work on ZFS so I either have to run on trim for my pools or schedule trim with systemd timers or cron. I have used btrfs in the past and there I ran trim on a schedule since it slowed me down a little to enable discard (trim). But on ZFS enabling trim doesn't seem to give me a performance hit at all so I was wondering if I still should set up trim on a weekly or monthly basis?


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 manual zpool 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.

| improve this answer | |
  • Thanks for great help. I have now set it up as you suggest. – Christian Jan 4 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.