Pcornel
Browse topics
Options
Recent
Favorites
Storage · Technical reference

Garbage Collection

Direct answer

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.

When to use this

Use this when SSD write performance drops over time.

First 30 seconds

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 %.

Operational verification

stale pages → GC moves valid data → erase → free blocks

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Physical storage media and interfaces
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformPhysical storage media and interfaces
Key commandlsblk --discard
Scope / prerequisiteUse this when SSD write performance drops over time.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points
  • GC frees blocks by moving valid pages.
  • TRIM helps GC.
  • Spare area reduces write amplification.
Key checks
  • fio sustained random write — performance drop when GC active
  • nvme smart-log /dev/nvme0 — writes
  • iostat -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 with fstrim -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
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docPhysical storage media and interfaces current

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%
Confirmation

Confirm action

Continue?