mapsize: see where your disk went
A disk usage analyser that lives in the terminal and shows you the answer as a picture. Point it at a folder and a treemap fills the screen, growing while the scan runs, with every block sized by what it actually costs on disk. Arrow keys move around the map, Space zooms in, and the 38 GB virtual machine you forgot about is the first thing you see.
- Rust
- Terminal UI
- Linux, macOS, Windows, BSD
- Open source
Role:
Sole designer & engineer
Stack:
Rust, one static binary
Status:
v2.0.0, GPLv3, on Homebrew
Install
On macOS or Linux with Homebrew, it is one line:
brew install andydixon/tap/mapsize
That builds it from source, puts mapsize on your path and installs the manual page, so man mapsize works straight away. brew upgrade picks up new releases.
Then run it on whatever is filling up:
mapsize ~ # explore your home folder
mapsize --read-only /srv # look, but never delete anything
mapsize --help # every flag
From my package repository
On Debian, Ubuntu, Fedora, RHEL, openSUSE or Arch, add repo.dixon.cx once and install mapsize with apt, dnf, zypper or pacman. It's signed, and updates arrive with the rest of your system.
Without Homebrew
Every release has packages for the common Linux distributions and archives for everything else, with SHA-256 checksums alongside.
# Debian, Ubuntu
curl -LO https://github.com/andydixon/mapsize/releases/download/v2.0.0/mapsize_2.0.0_amd64.deb
sudo apt install ./mapsize_2.0.0_amd64.deb
# Fedora, RHEL, openSUSE
sudo dnf install https://github.com/andydixon/mapsize/releases/download/v2.0.0/mapsize-2.0.0-1.x86_64.rpm
# Alpine
curl -LO https://github.com/andydixon/mapsize/releases/download/v2.0.0/mapsize_2.0.0_x86_64.apk
sudo apk add --allow-untrusted ./mapsize_2.0.0_x86_64.apk
# Arch
curl -LO https://github.com/andydixon/mapsize/releases/download/v2.0.0/mapsize-2.0.0-1-x86_64.pkg.tar.zst
sudo pacman -U ./mapsize-2.0.0-1-x86_64.pkg.tar.zst
# Anywhere with Rust
cargo install --locked --git https://github.com/andydixon/mapsize --tag v2.0.0
Packages are built for x86-64, ARM64, 32-bit x86, ARMv7 and RISC-V. Windows, macOS, FreeBSD and NetBSD get a zip or tarball with the binary, the manual page and the licence: unpack it and run.
The itch
When a disk fills up there are two kinds of tool. The ones that tell you, like du and ncdu, give you a sorted list one directory at a time. The ones that show you, like WinDirStat and WizTree, draw the whole disk as a picture where big things look big, and you spot the problem in a second. The trouble is that the disks I care about are usually on servers, at the other end of an SSH session, where the picture tools cannot follow.
So I wanted the picture in the terminal. Not a static chart printed at the end, but a proper interactive map I could move around, zoom into and filter, that started drawing the moment the scan began instead of making me wait for it to finish.
Moving around the map
Each block is a folder or file, sized by how much disk it really uses, and coloured by what kind of thing it is: video, archives, disk images, code, caches and so on. Folders show a preview of what is inside them, nested as deep as the space allows, and anything too small to draw is gathered into a single "N smaller items" block until you zoom in far enough to see it.
The arrow keys move to whichever block is actually to the left, right, above or below, the way your eyes expect, rather than stepping through a list. Space zooms into a folder, Backspace comes back out, and Enter opens the details: sizes, file counts, dates, owner and permissions.
Asking questions
Press / and type a question. The map redraws to show only what matches, so you can see where it lives as well as how much there is. The query language is small enough to guess:
*.isoorext IN (iso,qcow2,vmdk)for disk imagessize > 5GBfor the big stuffage > 365dfor things nobody has touched in a yearpath contains cache AND NOT type = dirto find what caches really hold
Other ways of looking
Tab switches between views of the same scan. File types totals everything by extension. Top lists rank the largest files and folders, the oldest and newest large files, the folders with the most entries, and any sparse or hard-linked files. Scan information lists every error and anything that was skipped, so you know exactly how complete the numbers are.
Duplicates
Press D and mapsize looks for files that are byte-for-byte identical. It groups by size first, samples, and only then hashes the survivors in full with SHA-256, so most files are never read at all. Nothing is reported as a duplicate unless the full hashes match.
The screenshots show a made-up home folder I generated for the purpose, not anyone's real files.
Rewritten in Rust, and measured
Version 2.0 is a complete rewrite of the original Go version in Rust: scanner, treemap, filters, snapshots, duplicate finder and the full terminal interface. It keeps the same flags, keys and screens, and the snapshot format is byte-for-byte the same, so 1.x and 2.0 open each other's files. Every release is now built, packaged and published by CI for Linux, macOS, Windows, FreeBSD and NetBSD.
1.2 and 2.0 ran the same benchmarks back to back, alternating, on the same machine (Intel Core i7-7700, ext4 on spinning disks). The scans covered 458,000 files and folders with a warm cache; the interface tests used a synthetic tree of a million entries drawn at 200×60.
| What | 1.2 (Go) | 2.0 (Rust) | Difference |
|---|---|---|---|
| Scan, 8 workers | 0.63 s | 0.47 s | 1.34× faster |
| Scan, 1 worker | 1.89 s | 1.52 s | 1.24× faster |
| Peak memory while scanning | 117 MB | 76 MB | 35% less |
| Scan and save a snapshot | 1.22 s | 0.75 s | 1.63× faster |
| Open a snapshot | 0.34 s | 0.23 s | 1.48× faster |
| Scan and export JSON | 1.27 s, 153 MB | 0.86 s, 76 MB | 1.48× faster, half the memory |
| Draw the map from scratch | 36.0 ms | 11.3 ms | 3.2× faster |
| Treemap layout, 300 blocks | 84 µs | 8.4 µs | 10× faster |
| Arrow key, including redraw | 1.50 ms | 1.31 ms | 1.14× faster |
| Filters over a million entries | 29–121 ms | 27–68 ms | 1.1–1.8× faster |
Scanning is mostly waiting on the kernel, so the gain there is modest: it comes from less bookkeeping per file, not faster disks. Memory and drawing improve the most, because Rust has no garbage collector and the drawing code allocates far less. Filters started out slower than in 1.2, and only overtook it once the path and wildcard matching stopped allocating for every file. The performance notes have the full tables and how to rerun them.
Engineering decisions
- Honest numbers: sizes are what files occupy on disk, not what they claim to be, and you can switch to logical size with
a. Hard links are counted once, likedudoes. Sparse files are flagged. If anything could not be read, the totals say they are incomplete rather than quietly undercounting. - Fast without being greedy: a bounded pool of workers scans directories in parallel and feeds results into the map as they arrive. On my test machine it gets through around a million entries a second from a warm cache, and holds 458,000 of them in under 80 MB.
- A layout that respects the terminal: the treemap is the squarified algorithm, snapped to character cells by rounding edges rather than widths, so neighbouring blocks always meet exactly. Resizing the window recomputes the layout for the new shape instead of stretching the old one, and the selection survives resizes, rescans and filters.
- Hostile filenames are data, not commands: a filename can contain escape sequences that would rewrite your terminal. Every name passes through one sanitiser that shows control characters as visible escapes, and the renderer refuses them again as a second line of defence.
- Careful with deleting: deleting always asks first. On a desktop, and on macOS and Windows, it moves things to the system's own bin. On a headless server, where no one will ever empty a bin, it deletes permanently after an "are you sure", re-checking that the item is still the one that was scanned.
--read-onlyswitches every destructive action off, for when you are poking around somewhere that matters. - Snapshots you can trust: save a scan, reopen it instantly, or compare two and see growth and shrinkage coloured on the map. The format is versioned and checksummed, and the loader treats every snapshot as hostile input, so a corrupt or malicious file fails cleanly.
What it demonstrates
Taking a familiar idea and finishing it properly for an awkward environment: concurrency that stays bounded under pressure, a layout engine built for a grid of characters, keyboard navigation that follows the geometry on screen, and the unglamorous security work a tool needs when it prints untrusted strings to a terminal. It ships as one binary for five operating systems, with Linux packages and a Homebrew tap, and the measurements in the repository are real ones.