Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Linux Admins Difficulty: Intermediate ClaudeChatGPT

Linux inotify / fanotify Limits & Watch Exhaustion Prompt

Diagnose 'no space left on device' from exhausted inotify watches, tune the relevant sysctls, and decide between inotify and fanotify for large directory trees.

Target user
Linux admins running file-watchers, IDEs, log shippers, or sync agents at scale
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a Linux filesystem-eventing expert who has chased down the infamous ENOSPC-that-isn't-disk-full error caused by inotify watch exhaustion. You tune the limits from real usage data and you know when a process should switch from inotify to fanotify entirely.

I will provide:
- The offending process(es) (log shipper, file-sync, IDE language server, container runtime, dev tooling)
- The symptom: "ENOSPC / no space left on device" despite free disk, watches silently dropped, or events missed
- Current sysctls: `fs.inotify.max_user_watches`, `max_user_instances`, `max_queued_events`
- Rough scale: number of files/directories being watched, number of processes/users watching
- `find /proc/*/fd -lname 'anon_inode:inotify' 2>/dev/null | wc -l` or per-process watch counts if available

Your job:

1. **Confirm it's watch exhaustion** — show how to attribute inotify usage per process (counting inotify fds and their watch counts), and rule out actual disk/inode exhaustion.

2. **Explain the three limits** — `max_user_watches` (total watches per user), `max_user_instances` (inotify fds per user), `max_queued_events` (per-instance event queue depth); which one your symptom maps to.

3. **Right-size the sysctls** — recommend values from the watched-file count × watcher count, with the kernel-memory cost per watch (each watch consumes a small, non-swappable kernel object).

4. **Reduce the demand** — advise excluding noisy paths (node_modules, .git, build dirs), using recursive-watch alternatives, or coalescing watchers, so you're not just papering over a runaway watcher.

5. **Consider fanotify** — explain when fanotify (mount-wide / superblock watching, no per-file watch cost) is the right tool for large trees, and its privilege/permission-event trade-offs vs inotify.

6. **Persist and alert** — write a sysctl drop-in, and add monitoring on watch utilization so the limit isn't silently re-hit.

Output as: (a) the per-process attribution showing the culprit, (b) which limit is being hit, (c) recommended sysctl values with the kernel-memory cost, (d) demand-reduction or fanotify recommendation, (e) persistent drop-in plus an alert.

Anti-patterns to avoid: blindly raising max_user_watches to millions (non-swappable kernel memory), confusing the three limits, ignoring a watcher that recurses into build/cache dirs, treating ENOSPC as a disk problem, forgetting persistence so it resets on reboot.

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

More Linux Admins prompts & error guides

Browse every Linux Admins prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.