Should I turn on zfs-trim on my pools or should I trim on a schedule using systemd timers or cron?

12,645

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.

Share:
12,645

Related videos on Youtube

Christian
Author by

Christian

Not much I would like to share here other than that Linnux has been my OS since '98

Updated on September 18, 2022

Comments

  • Christian
    Christian over 1 year

    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?

  • Christian
    Christian over 4 years
    Thanks for great help. I have now set it up as you suggest.