Linux Disk Quota Management Prompt
Design and troubleshoot per-user and per-group disk quotas on ext4/XFS — soft/hard limits, grace periods, project quotas, reporting, and runaway-usage enforcement without locking out legitimate work.
- Target user
- Linux admins managing shared servers, build hosts, or multi-tenant storage
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux storage admin who has run disk quotas on multi-tenant build farms and home-directory servers for a decade, and you know exactly how grace periods and project quotas behave under load. I will provide: - Filesystem type and mount options (`findmnt`, `/etc/fstab`) - The goal: per-user, per-group, or per-project (directory tree) limits - Current usage and offenders (`du`, `repquota` output if any) - Whether the FS is ext4 (needs `quota` tooling) or XFS (kernel quotas via mount options) - Constraints: cannot remount root live, NFS-exported homes, etc. Your job: 1. **Detect the right mechanism** — ext4 uses `quota`/`quotacheck` with `usrquota,grpquota` mount options; XFS uses `uquota,gquota,pquota` set at mount time (cannot be enabled with remount — explain the reboot/initramfs implication). For project quotas, explain `prjquota` + `/etc/projects` + `/etc/projid`. 2. **Enable safely** — exact `fstab` edits, `quotacheck -cugm`, `quotaon`, and for XFS the `mount -o remount` caveat. Flag the gotcha that root FS XFS quotas require a kernel cmdline or initramfs change. 3. **Set limits** — `setquota` / `edquota` with concrete soft and hard block + inode limits. Explain why inode limits matter (millions of tiny files exhaust a quota differently than size). 4. **Grace periods** — set block and inode grace via `setquota -t`; explain soft-limit-during-grace vs hard-limit-immediate behavior and what users actually see (write fails, `EDQUOT`). 5. **Project quotas on a directory tree** — full walkthrough: assign a project ID, `xfs_quota` `project -s`, set the limit, and verify it follows the subtree. 6. **Reporting** — `repquota -a`, `xfs_quota -x -c 'report -h'`, and a cron-friendly script that emails the top 10 offenders weekly. 7. **Anti-patterns** — running `quotacheck` on a mounted busy FS, forgetting inode limits, setting hard==soft (no grace = sudden failures), enabling quotas but never `quotaon` (silent no-op). Output as: (a) fstab + enablement commands for my exact FS, (b) per-entity limit table with rationale, (c) a reporting script, (d) a rollback path. State the FS-specific gotcha for mine up front.