Check out my first novel, midnight's simulacra!

TRIM

From dankwiki
Revision as of 01:55, 20 March 2024 by Dank (talk | contribs) (Created page with "SSDs generally need to have the blocks belonging to a file explicitly deallocated. This is done with the ATA TRIM command. Unfortunately, regular use of TRIM can have negative effects on performance (TRIM cannot be queued on some devices) and lifetime. It is thus not generally recommended to trim after every delete operation, though this can be configured ("online mode"). Note that trimming generally requires the filesystem to be mounted, unlike e.g. <tt>fsck</tt>. Note...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SSDs generally need to have the blocks belonging to a file explicitly deallocated. This is done with the ATA TRIM command. Unfortunately, regular use of TRIM can have negative effects on performance (TRIM cannot be queued on some devices) and lifetime. It is thus not generally recommended to trim after every delete operation, though this can be configured ("online mode"). Note that trimming generally requires the filesystem to be mounted, unlike e.g. fsck. Note also that TRIM can have negative impacts on the security of encrypted filesystems.

A device which doesn't support TRIM will be rejected by fstrim with an error, so it's safe to run on arbitrary filesystems.

Online mode

  • Use the discard option when mounting
  • On ZFS, set the autotrim pool option

Explicit

  • fstrim -v filesystem
  • On ZFS, zpool trim poolname
  • On md or DM, all devices in the pool must support TRIM, or it will be rejected

Periodic

  • systemctl enable fstrim.timer