Mass Storage & Disk Scheduling

the TRIM command

/ trim /

Imagine a self-storage warehouse where you rent numbered lockers. When you move out of a locker, if you never tell the front desk, they keep treating it as occupied — and worse, when they reorganise the building they carefully preserve your old junk, wasting effort. If you simply tell them 'locker 12 is empty now', they can ignore its contents and reuse it freely. The TRIM command is the file system telling an SSD exactly this: 'these logical blocks are no longer in use, you may forget them.'

Concretely, here is the problem TRIM solves. When you delete a file, the file system just removes its directory entry and marks its blocks free in its own bookkeeping — it does not wipe the data, and crucially it does not tell the drive. The SSD's flash translation layer, which knows nothing of files, still believes those blocks hold valuable data, so during garbage collection it dutifully copies that now-useless data around to preserve it, wasting writes and erase cycles. TRIM (sometimes called discard or, in the SCSI world, UNMAP) fixes this: when blocks are freed, the OS sends the drive a TRIM telling it which logical blocks are now garbage. The FTL can then drop them, skip copying them during garbage collection, and have more genuinely-free space to work with.

Why it matters: without TRIM, an SSD slowly fills up with data the file system has already abandoned, garbage collection grows more expensive, write amplification rises, and write performance degrades over time — the classic 'SSD slows down once it has been used a while' effect. With TRIM, the drive stays informed and stays fast. Note that TRIM is purely a hint to help the drive, not a guarantee about your data: it is not a secure erase (the data may linger physically for a while), and it relies on the OS, file system, and drive all supporting and using it correctly.

You delete a 2 GB video. The file system marks those blocks free and issues TRIM for them. Now the SSD knows those pages are garbage, so its next garbage-collection pass simply erases them instead of laboriously copying 2 GB of dead video to keep it 'safe'.

TRIM tells the drive what the file system already knows: this is junk.

TRIM is a performance and longevity hint, not a security tool. Issuing TRIM does not securely wipe data, and on a plain hard disk it does nothing useful at all — it is meaningful only for flash-based drives.

Also called
TRIMdiscardUNMAP丟棄指令