Skip to content

Recipes

Outcome: four questions people actually ask, each answered by one command from the earlier chapters. Every recipe here was run in the lab; the outputs quoted are the lab machine's.

"What is fullest? Show me the worst first"

Sorting is ascending only (chapter 6), so the fullest filesystems are at the end of a usage sort — take the tail:

./duf --only local --sort usage | tail -8

The lab's tail was a row of small read-only system images at 100.0% — a reminder that "fullest" and "problem" are different questions: a sealed 1.2G image at 100% is supposed to be full. Read the tail with the AVAIL column in mind, not just the percentage.

"Name every filesystem over 90% full"

For a script or a morning report, the JSON form beats scraping a table. Divide used by total, keep the worst, print plainly:

./duf --json | jq -r '.[] | select(.total > 0) | select(.used / .total > 0.9) | "\(.mount_point) is \((.used / .total * 100) | floor)% full"' | sort -u
/etc/hosts is 100% full
/etc/resolv.conf is 100% full
/home/hatch/assets is 100% full
/opt/hatch is 100% full
/opt/muse/assets is 100% full
/opt/muse/skills is 100% full

The sort -u matters: filesystems mounted at several points (and the JSON lists every mount, chapter 9) would otherwise repeat. On a machine with real disks this same line is a serviceable cron check — it prints nothing at all when nothing is over the line, and a cron job that prints nothing sends no mail.

"Is anything about to run out of inodes?"

The inode budget of chapter 8, in one line per filesystem, straight from the JSON's inode fields:

./duf --json | python3 -c "import json,sys; [print(m['mount_point'], m['inodes_used'], 'of', m['inodes']) for m in json.load(sys.stdin) if m['mount_point']=='/tmp']"
/tmp 653 of 1015613
/tmp 653 of 1015613

Swap /tmp for the mount you worry about — mail spools and cache folders are the classics — and remember the btrfs lesson: a row reporting 0 of 0 is a filesystem where the question does not apply, not a filesystem in trouble.

"Prove duf and df agree before I trust the pretty table"

The guide's own checker, kept in the lab folder:

./duf --json | python3 duf-lab/check-json.py

It prints the array's size, the (deliberately meaningless) grand total with its double-counting warning, and the root filesystem's byte counts from duf beside df's — the chapter 9 check, kept as a runnable receipt. Run it once on any machine you adopt duf on; after that, the pretty table has earned its place.