Use this when SSDs should learn which blocks are unused.
TRIM
TRIM (UNMAP for SCSI, Deallocate for NVMe) tells an SSD which blocks the file system no longer uses, so garbage collection can reclaim them. On Linux run fstrim regularly; Windows does it automatically.
1. TRIM/discard tells the SSD which blocks are free.
2. Improves performance and endurance.
3. Use periodic fstrim rather than discard mount option for most.
4. Through LVM/crypt/VMs, discard must pass every layer.
5. Thin pools reclaim space too.
delete → discard → SSD/thin pool frees blocks
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Prove discard reaches the intended owner layer Verify boundary
Use a controlled file or block allocation, record allocation at the filesystem and thin/backend layer, delete or free the data, then run the platform’s intended discard path. Confirm the request is accepted through intermediary layers and that reclaim becomes visible where capacity is actually provisioned. For performance problems, repeat the original write workload and compare latency rather than relying on free-space counters alone. Verify the selected periodic or online discard policy persists after reboot or remount. The limit of what it shows is the intended backend observing reclaimed blocks or the original SSD workload recovering—not merely a successful fstrim or filesystem capability flag.
Step 2 Avoid treating TRIM as a universal SSD repair Narrow the fault
If deleted space is not reclaimed in a thin-provisioned backend, trace discard capability through every layer: filesystem, logical volume, virtual disk, hypervisor or storage array. If the goal is SSD performance, first show there is a write-latency or garbage-collection problem rather than assuming missing TRIM. Continuous discard can add overhead on some stacks, while periodic discard may be preferable; the correct policy depends on platform behavior. A manual discard command that succeeds syntactically does not show the backend reclaimed capacity. Compare allocated versus used space at the layer that owns provisioning, and inspect device or array counters when available.
Step 3 Branching troubleshooting Narrow the fault
Concrete boundaries: block request → host queue/driver → controller/firmware → media → completion status/latency → filesystem/application read-back.
Step 4 Common mistakes Narrow the fault
- TRIM disabled or not passed through virtualisation/RAID layers.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- TRIM/UNMAP/Deallocate.
- Run fstrim regularly on Linux.
- Thin storage reclaims space with it.
lsblk -D— discard supportfstrim -av— trim mounted filesystemssystemctl status fstrim.timer— periodic trim
ReferenceHow it works2 sections · depth on demand
Discard propagation through layered storage
TRIM is the ATA term commonly associated with notifying flash storage that logical blocks are no longer in use; in Linux and many generic storage discussions the operation is exposed as discard. The key operational issue is propagation. A filesystem can generate discard requests, but device-mapper layers, thin provisioning, encryption, virtualization, SAN presentation or controller policy may choose to pass, translate, defer or ignore them. Some systems issue online discard during deletion, while others batch discards periodically. The SSD can use this information for internal garbage collection and free-block management, but the timing of any performance benefit is implementation-specific. Treat “filesystem supports discard” and “device received discard” as separate boundaries.
How it works
Block I/O reaches a device queue/controller, firmware translation/cache and NAND or magnetic media. SMART/NVMe health fields are indicators with vendor-defined thresholds; “PASSED” does not show absence of latency spikes, path errors or filesystem corruption. Queue depth, thermal throttling, media errors and controller resets can affect workload independently.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
TRIM (ATA) and its equivalents UNMAP (SCSI) and Deallocate (NVMe) tell an SSD or thin-provisioned storage which blocks the filesystem no longer uses. The SSD can then erase them in the background, keeping write performance steady, and thin pools can reclaim the space.
| Method | How |
|---|---|
| Periodic | fstrim via systemd timer (weekly) — recommended |
| Continuous | discard mount option — immediate, can cost performance |
| Windows | Automatic "Optimize Drives"; fsutil behavior query DisableDeleteNotify |
| VMs | Virtual disk must pass discard through (e.g. discard=on in KVM) |
lsblk --discard
systemctl status fstrim.timer
sudo fstrim -av
Optimize-Volume -DriveLetter C -ReTrim -Verbose
For thin-provisioned LUNs and VM disks, TRIM/UNMAP must work through every layer (guest, hypervisor, array) to actually free space.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Physical Storage Media → SSD → TRIM. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://nvmexpress.org/specifications/ · confidence 94%