Linux fstrim & SSD Discard Maintenance Prompt
Set up correct TRIM/discard for SSDs and thin-provisioned storage on Linux — periodic fstrim vs continuous discard — across LVM, LUKS, and dm-crypt stacks without hurting performance.
- Target user
- Linux admins managing SSD-backed or thin-provisioned servers and VMs
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Linux storage admin who gets TRIM right across the full device-mapper stack so SSDs keep their write performance and thin pools actually reclaim space — without paying the latency tax of inline discard. You distinguish periodic fstrim from continuous `discard` and you know each layer that must pass TRIM through. I will provide: - The storage stack top-to-bottom (filesystem → LVM → LUKS/dm-crypt → device, or VM virtual disk → host) - Device type: physical SSD/NVMe, thin LVM pool, SAN LUN, or virtualized disk - Current setup: `fstab` mount options, `systemctl status fstrim.timer`, `lsblk --discard` (DISC-GRAN/DISC-MAX) - The goal/symptom: declining write performance, thin pool not reclaiming space, or unclear whether TRIM reaches the device Your job: 1. **Verify discard support end-to-end** — use `lsblk --discard` to confirm non-zero DISC-GRAN at each layer; identify any layer (LUKS, dm-crypt, virtual disk controller) that swallows TRIM and how to enable pass-through. 2. **Choose periodic vs continuous** — recommend the `fstrim.timer` (weekly is the sane default) over the `discard` mount option in almost all cases; explain why inline `discard` adds per-delete latency and can stress some SSDs. 3. **Enable pass-through per layer** — `discard` in crypttab (`rd.luks.options=discard` / `allow-discards`) with its security trade-off, `issue_discards = 1` in lvm.conf for thin pools, and the VM/host side for virtual disks. 4. **Tune the schedule** — set the fstrim.timer cadence to the workload's delete rate; for very high-churn filesystems explain when more frequent trimming helps. 5. **Validate reclamation** — run `fstrim -v` and show bytes trimmed; for thin pools confirm the pool's data% drops after trim. 6. **Note the security trade-off** — enabling discard on LUKS leaks which blocks are unused; state when that's acceptable and when to keep it off. Output as: (a) the per-layer discard-support audit, (b) periodic-vs-continuous recommendation, (c) the exact config changes per layer, (d) the timer cadence, (e) validation commands and the LUKS security caveat. Anti-patterns to avoid: using the `discard` mount option by default, assuming TRIM passes through LUKS/thin pools when a layer drops it, enabling LUKS discard without acknowledging the information leak, trimming a SAN LUN that doesn't support it, never verifying bytes were actually trimmed.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Linux bcache SSD Caching Setup Prompt
Design a bcache SSD-in-front-of-HDD caching tier with the right cache mode, write policy, and sequential-bypass tuning, and plan the attach/detach and failure behavior so a cache device loss never means data loss.
-
Linux nvme-cli SSD Health Management Prompt
Interpret nvme-cli smart-log, error-log, and self-test output to decide whether an NVMe drive is healthy, wearing out, thermally throttling, or in pre-failure, and plan namespace, firmware, and format actions safely.
-
Linux fio Storage Benchmark Design Prompt
Design fio job files that model your real workload (block size, queue depth, read/write mix, fsync policy) and interpret IOPS, throughput, and latency percentiles without fooling yourself with cache or preconditioning artifacts.
-
rsync Large-Dataset Migration & Verification Prompt
Plan, tune, and verify a large rsync data migration (terabytes / millions of files) — pick the right flags, avoid resync churn, throttle load, and prove the copy is byte-correct before cutover.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.