Use this when SSD write performance drops over time.
Garbage Collection
Garbage collection in an SSD moves still-valid pages out of partly used blocks and erases them, so new writes have empty blocks. TRIM and spare area make it more efficient and reduce write amplification.
1. Garbage collection consolidates valid pages to erase blocks.
2. Causes write amplification and latency spikes.
3. More free space/TRIM reduces it.
4. Enterprise drives handle it better.
5. Avoid filling SSDs to 100 %.
stale pages → GC moves valid data → erase → free blocks
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
lsblk --discardVerification & 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 Checking TRIM Verify boundary
lsblk --discard # Linux: non-zero DISC-GRAN = TRIM supported
systemctl status fstrim.timer # weekly TRIM
fsutil behavior query DisableDeleteNotify # Windows: 0 = TRIM enabled
In VMs, TRIM/UNMAP must pass through the virtual disk (e.g. discard=on in Proxmox) to reach the storage.
Step 2 Common mistakes Narrow the fault
- Filling SSDs to 100 %, leaving no room for garbage collection.
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.
- GC frees blocks by moving valid pages.
- TRIM helps GC.
- Spare area reduces write amplification.
fio sustained random write— performance drop when GC activenvme smart-log /dev/nvme0— writesiostat -x 1— latency spikes
ReferenceHow it works1 section · depth on demand
Helping garbage collection
- TRIM/UNMAP/Deallocate tells the SSD which pages are free, so it does not copy dead data. Enable
fstrim.timer(Linux) or keep "Optimize Drives" scheduled (Windows); check withfstrim -v /. - Leave free space or extra over-provisioning (for example 10–20 % unpartitioned on write-heavy drives).
- Thin-provisioned VMs need UNMAP passed through (discard options in the hypervisor).
Without these, write latency rises sharply when the drive is nearly full.
ReferenceImportant terms & boundaries2 sections · depth on demand
Over-provisioning
Leaving 10–20 % of an SSD unpartitioned (after a secure erase) gives the controller more free blocks and reduces write amplification under heavy random writes. Enterprise "mixed-use" drives (e.g. 3.2 TB instead of 3.84 TB) already include extra over-provisioning.
In depth
Garbage collection reclaims blocks containing invalid pages: it copies still-valid pages elsewhere, then erases the block. It runs in the background, but when free blocks run low it runs in the foreground and causes latency spikes and lower write throughput — the "write cliff" seen in sustained random-write tests.
What helps: TRIM/UNMAP (tells the drive which pages are invalid), over-provisioning (more spare blocks), sequential write patterns, and enterprise drives designed for steady-state performance.
nvme id-ctrl /dev/nvme0 | grep -i oncs # DSM (deallocate/TRIM) support
lsblk --discard # DISC-GRAN > 0 means discard supported
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 → Garbage Collection. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://nvmexpress.org/specifications/ · confidence 94%