Check out my first novel, midnight's simulacra!

TRIM

From dankwiki

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