Skip to content

Duf for Mere Mortals

Every computer answers one question badly: how much disk space is left? The old answer is df, a tool from the earliest days of Unix, whose output is a wall of numbers in units nobody chose. Duf is the same answer, rebuilt for human eyes. It asks the system the same question df asks, then presents what comes back as grouped, sorted tables — real disks in one table, the system's own housekeeping mounts in another — with sizes given to one decimal place and a small bar that fills as a filesystem fills.

This guide explains how duf sees a machine, how to install it, and how to read its table without being misled by it. Then it does the thing a prettier df most needs done: it checks duf's numbers against df itself, byte for byte, and reports where the two tools agree, where they round differently, and where — in this lab, at least — duf's tidied-up default view quietly left the root filesystem out of the picture altogether. Knowing that is the difference between using duf and trusting it blindly.

The lab behind this guide ran the real thing: duf 0.9.1, the official release binary, on a small Linux machine with an unusually crowded mount table — 76 mounted filesystems, most of them bind mounts and memory filesystems belonging to the machine's own plumbing. Against that crowd the lab ran duf's default view beside df -h, sorted by size and by fullness, filtered by group, by filesystem type and by mount point, asked for inodes instead of blocks, changed the columns, the width, the style and the colour thresholds, and took the whole inventory as JSON into jq and a small Python checker that compared duf's root-filesystem figures with df's own — and found them identical, to the byte. It also broke things on purpose: a flag that does not exist, a path that does not exist, a sort key that does not exist, and a JSON field name that sounds right and is wrong.

What the lab could not do, it did not fake. Its terminal was a capture pipe, not a screen, so duf's colours never resolved there — the guide proves the colour codes are emitted and the bar is drawn, and describes the colours themselves from the documentation, labelled as such. The lab machine had no network filesystems, so duf's network group is shown empty and described, not demonstrated on a live NFS mount. criteria.md keeps the full ledger of what was run and what was only read.

What this guide covers

  • What duf is — the mental model: one question, asked of the kernel, presented for humans — and what duf deliberately is not
  • The moving parts — the mount table, the statfs call that answers for each mount, the groups duf sorts mounts into, the filter that tidies the default view, and the renderer that draws the table
  • Installing duf — the release download, the checksum that proves the file is the file, and the version check
  • Your first run — the default view beside df -h, the grouped tables, and asking about one path at a time
  • Reading the table — the seven columns, the usage bar, one-decimal sizes, and why duf's percentages are not df's percentages
  • Sorting and choosing columns — every sort key, the ascending-only catch, and building a table with just the columns you want
  • Groups and filtering — local, network, special and the rest; showing and hiding by group, by filesystem type and by mount point, wildcards included
  • The inode view — the other way a filesystem fills up: running out of file slots while space remains, checked against df -i
  • JSON output — the full inventory as data: the real field names, jq queries that work, a byte-for-byte check against df, and why the JSON list is longer than the table
  • Width, style and themes — fitting the table to the terminal, the ASCII style, the colour themes and thresholds, and what survives being piped into a file
  • Recipes — worst-first fullness reports, a script that names every filesystem over 90% full, and an inode check in one line
  • The neighbours — df itself, dust and ncdu and the different question they answer, and where duf sits among them
  • Limits — filesystems yes, files no; a default view that can hide the disk you asked about; snapshots, not monitoring; and the rest, stated plainly
  • Troubleshooting — the empty answer that means "filtered, not missing", the JSON field that answers null, the flag that costs you a page of usage text, and the traps this guide's lab fell into
  • Glossary — the terms, collected in one place

What it doesn't cover

What is inside a filesystem — which folders ate the space — is a different question with its own tools; the dust and ncdu guides in this series answer it, and chapter 12 explains the boundary. Mounting and unmounting, partitioning, and repairing filesystems are pointed at, not taught: duf reports on mounts, it never touches them. Monitoring over time — graphs, alerts, history — is also out: duf is a snapshot, and chapter 13 says so.

How to use this guide

Read chapter 1 for the model and chapter 2 before installing anything — knowing which part holds what turns later surprises into named behaviour, including the day duf's default view leaves a filesystem out. Chapters 3 and 4 get you a running duf and a first table in the same sitting. Chapter 5 is the one to read slowly: its rounding and percentage details are how you keep a prettier tool from quietly changing the facts. The lab's transcripts live in duf-lab/transcripts/ and its checker script is duf-lab/check-json.py.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.