Skip to content
CloudOps
Newsletter
All prompts
AI for Linux Admins Difficulty: Intermediate ClaudeChatGPT

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

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week