Check out my first novel, midnight's simulacra!

TRIM: Difference between revisions

From dankwiki
(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...")
 
No edit summary
 
Line 2: Line 2:


A device which doesn't support TRIM will be rejected by <tt>fstrim</tt> with an error, so it's safe to run on arbitrary filesystems.
A device which doesn't support TRIM will be rejected by <tt>fstrim</tt> with an error, so it's safe to run on arbitrary filesystems.
TRIM is engaged from userspace using the FITRIM ioctl.


==Online mode==
==Online mode==

Latest revision as of 01:59, 20 March 2024

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.

TRIM is engaged from userspace using the FITRIM ioctl.

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