No description
  • C 94.2%
  • Shell 4.8%
  • Makefile 0.8%
  • Dockerfile 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-03 21:45:48 +01:00
docs Label and open separate mounts in the explorer 2026-11-03 21:45:48 +01:00
src Label and open separate mounts in the explorer 2026-11-03 21:45:48 +01:00
tests Make merged mounts selectable in the live view 2026-11-03 21:45:48 +01:00
.dockerignore Add Nicer Disk Usage 2026-11-03 20:42:04 +01:00
.gitignore Add Nicer Disk Usage 2026-11-03 20:42:04 +01:00
CHANGELOG.md Label and open separate mounts in the explorer 2026-11-03 21:45:48 +01:00
compose.yaml Add Nicer Disk Usage 2026-11-03 20:42:04 +01:00
Dockerfile Add Nicer Disk Usage 2026-11-03 20:42:04 +01:00
LICENSE Add Nicer Disk Usage 2026-11-03 20:42:04 +01:00
Makefile Add Nicer Disk Usage 2026-11-03 20:42:04 +01:00
README.md Label and open separate mounts in the explorer 2026-11-03 21:45:48 +01:00

Nicer Disk Usage

ndu shows how full your disks are. It is a friendlier df: one table per kind of filesystem, usage bars that turn yellow and red as disks fill up, merged duplicate mounts and none of the pseudo filesystems you never asked about. It also has a live view that shows how fast each disk is filling, and an explorer that finds what takes the space.

It is written in C, needs no libraries and builds into a single small binary.

╭─ Local disks ──────────────────────────────────────────────────────────── 5 ─╮
│ MOUNTED ON        SIZE  USED  AVAIL                 USE%  TYPE    DEVICE     │
│ /                 100G   60G    35G  █████████─────  64%  ext4    nvme0n1p2  │
│  └ /var/lib/docker                                                           │
│ /boot/efi         512M   32M   480M  █─────────────   7%  vfat    nvme0n1p1  │
│ /home             932G  866G    65G  █████████████─  93%  btrfs   sda1       │
│ /media/usb stick   60G   11G    48G  ██▋───────────  19%  exfat   sdc1       │
│ /mnt/backup       3.6T  3.5T    94G  █████████████▊  98%  xfs ro  sdb1       │
╰────────────────────────────────────────────── 4.5T of 4.7T used · 243G free ─╯
╭─ Network shares ───────────────────────────────────────────────────────── 2 ─╮
│ MOUNTED ON        SIZE  USED  AVAIL                 USE%  TYPE    DEVICE     │
│ /mnt/media        7.3T  3.6T   3.6T  ███████───────  50%  nfs4    nas:/expo… │
│ /mnt/office       not responding                          cifs    //server/… │
╰──────────────────────────────────────────────────────────────────────────────╯
 Not shown: 1 loop, 2 memory, 2 system · ndu -a shows everything

Features

  • Readable at a glance. Filesystems are grouped into local disks, network shares, FUSE, loop images, memory and system. Bars and percentages are green, yellow from 75% and red from 90%, and you can move both thresholds.
  • No noise. /proc, cgroups, snap loops and tmpfs are hidden until you ask for them, and the line under the table says how many were left out. A btrfs subvolume or bind mount of a disk that is already listed is shown as a └ line under it, not as a second identical row.
  • Fits any terminal. Columns drop out in a sensible order as the window narrows, down to 40 columns. Output to a pipe or file is plain text, and --ascii avoids Unicode completely.
  • Never hangs. A dead NFS server or a stuck sshfs mount is shown as "not responding" after two seconds instead of freezing the whole command, which plain df will do.
  • Details on demand. -d shows a card per filesystem: exact byte counts, space reserved for root, inodes, the disk model and whether it is an NVMe, SSD, HDD or USB drive, label, UUID and mount options.
  • Live view (-I) refreshes every two seconds, shows the selected disk's details under the table and adds a RATE column with how fast each filesystem fills or frees space, and when it would be full at that pace. Sort, inodes, units and the full list are one key away; the mouse works too.
  • Explorer (-e PATH, or e in the live view) scans a folder and lists what takes the space, biggest first, with a list of the largest files. It stays on one filesystem and counts hard links once. Piped, it prints a report instead.
  • For scripts: --json, and ndu PATH... shows the filesystems that hold given paths.

Install

You need a C compiler and make. No libraries are required.

git clone https://git.turbotux.xyz/michanical/ndu.git
cd ndu
make
sudo make install

make install honors PREFIX and DESTDIR and installs the man page. To remove it again, run sudo make uninstall.

On the BSDs, make and gmake both understand the Makefile. For a static binary on Alpine Linux:

apk add build-base
make LDFLAGS=-static
System Status
Linux with glibc Tested
Alpine Linux with musl, static binary Tested in Docker
FreeBSD, NetBSD, OpenBSD, DragonFly, macOS Written for (getmntinfo), not yet compiled or run there

Usage

ndu                    # local disks, network shares and FUSE mounts
ndu -a                 # everything, including tmpfs, loops and /proc
ndu ~/Videos /mnt/usb  # only the filesystems holding these paths
ndu -d /               # a detailed card for the root filesystem
ndu -s use             # fullest first; also size, used, avail, type, device, mount
ndu -i                 # inodes instead of space
ndu -l --si            # local disks only, in powers of 1000
ndu -t ext4,xfs        # only these types; -x hides types instead
ndu -g local,memory    # pick groups: local, network, fuse, loop, memory, system
ndu --json | jq '.filesystems[] | select(.use_percent > 90) | .mount'
ndu -I                 # live view
ndu -e ~               # what takes the space in your home folder

ndu --help lists every option and man ndu explains them.

Live view keys

Key Action
↑ ↓ j k, PgUp PgDn Home End select a filesystem
Enter → details of the selected filesystem
e explore what takes the space on it
s / r sort by the next column / reverse the order
i switch between space and inodes
a show every filesystem, or only disks and shares again
u units: powers of 1024, powers of 1000, bytes
F5 Ctrl+L refresh now
? help
q Esc quit

Mounts that share a filesystem with the row above them, such as a btrfs /home under /, get their own └ rows here. Select one to see its own details and mount options, or press e to explore it.

A click selects a row, a second click opens its details and the wheel scrolls. The RATE column needs two refreshes before it shows anything; it is a smoothed average of what ndu saw while it was running.

Explorer keys

Key Action
Enter → l open the selected folder
Enter on a mount scan that mount on its own; Esc comes back
← h Backspace go up
s sort by size, name or number of files
a size on disk or apparent size (file length)
f the 50 largest files found
r scan again
q Esc leave the explorer

The scan does not cross into other mounts. They are listed with their name and a note: "mounted separately" for another mount of the same filesystem, such as /home on a btrfs root, and "other filesystem" for the rest.

Configuration

There is no configuration file; options go on the command line, and a shell alias such as alias df='ndu' makes your favourite ones permanent. ndu reads these environment variables:

Variable Effect
NO_COLOR turns colors off unless --color=always is given
COLUMNS output width when writing to a pipe or file (default 100)
TERM dumb turns colors off; linux (the text console) uses simpler box characters
LANG, LC_ALL, LC_CTYPE a non-UTF-8 locale switches to ASCII characters

Docker

The image is a static Alpine build. Inside a container ndu sees the container's own mounts, so compose.yaml bind-mounts the host's root read-only at /host; the host's disks then appear under /host.

docker compose run --rm ndu          # table
docker compose run --rm ndu -I       # live view
docker compose run --rm ndu -e /host/home

Development

make            # ./ndu
make test       # unit tests, output tests, end-to-end tests through tmux
make lint       # everything with warnings as errors
make sanitize   # build with AddressSanitizer and UBSan; run make test afterwards
make clean

The end-to-end tests need tmux and are skipped without it. The output tests compare ndu's output on a made-up machine with the files in tests/expected/; after an intended change to the output, regenerate them with UPDATE=1 sh tests/output.sh and review the diff.

The made-up machine is tests/fixtures/mixed.txt. Setting NDU_FIXTURE to such a file makes ndu read it instead of the real mount table, which is how the tests get the same output on every machine. Each line is source target type options size used avail inodes inodes_free device_id, or source target type options timeout|error for a filesystem that cannot be read.

Project layout

Path What it holds
src/mountinfo.c, src/mounts_os.c reading the mount table: the portable parsers and the Linux and BSD readers
src/fs.c grouping, statvfs with a timeout, merging duplicates, filtering and sorting
src/table.c, src/details.c, src/render.c the table, the detail card, and the styled lines both are built from
src/tui.c, src/term.c, src/ui.c the live view and the terminal handling under it
src/scan.c, src/explore.c the folder scanner and the explorer screens
src/devinfo.c disk model, kind, label and UUID from /sys and /dev/disk on Linux

License

MIT, see LICENSE.