$linuxjunkies
>

discard (TRIM)

also: TRIM, fstrim, ATA TRIM, discard

TRIM is a command that tells SSDs which data blocks are no longer in use, allowing the drive to optimize performance and lifespan by erasing unused space. It bridges the gap between the filesystem's view of deleted data and the SSD's physical memory management.

When you delete a file on a traditional hard drive, the filesystem simply marks the space as free but doesn't erase it—the drive doesn't need to. SSDs work differently: they must erase cells before rewriting them, making this process expensive. TRIM tells the SSD "this data is no longer needed" so it can proactively erase blocks, avoiding performance degradation when new writes come in.

Linux supports TRIM through the fstrim command (manual) or by enabling continuous TRIM in mount options (discard flag). For example, mount -o discard /dev/sda1 /mnt enables real-time TRIM, though batch TRIM via fstrim / is often preferred for stability.

Without TRIM, SSDs can become noticeably slower over time as the controller struggles to find erased space for new writes. Modern Linux systems typically run fstrim weekly via a systemd timer to balance performance with SSD longevity.

Related terms