macdisksleuth

The truth engine

MacDiskSleuth’s job is to answer two questions honestly on modern macOS:

  1. What is really on this disk?
  2. What will deleting this really give back?

APFS makes both questions harder than they look, and most tools answer them with numbers designed for a filesystem Apple retired in 2017. This document defines exactly what MacDiskSleuth’s numbers mean.

The three lenses

Lens Source Meaning
Logical ATTR_FILE_DATALENGTH What files claim to be. Matches ls -l and most tools.
Physical ATTR_FILE_ALLOCSIZE, shared bytes counted once What the disk actually holds.
Freeable ATTR_CMNEXT_PRIVATESIZE + group analysis What deleting the item frees right now.

Why they diverge:

Where shared bytes are counted

Shared bytes are counted once, in the deepest folder that contains all files sharing them.

That single rule makes per-folder numbers deterministic and keeps every level of the tree self-consistent:

The diverged-clone honesty rule

Writing into a clone splits it from its APFS clone family (it gets a new clone ID) even though unwritten extents remain physically shared. macOS exposes no way to re-link those files. MacDiskSleuth handles this the only honest way:

Space that isn’t files

macdisksleuth overview reconciles the numbers Finder, df, and Apple’s Storage pane each report differently:

What the scanner reads (and what it never does)

Verifying it yourself

# make a clone and watch du lie:
dd if=/dev/urandom of=orig.bin bs=1m count=64
cp -c orig.bin clone.bin
du -sh .                      # ~128M — wrong
macdisksleuth scan . --depth 1   # physical ~64M — right
macdisksleuth info clone.bin     # "Deleting frees ~0 B now"

The test suite builds real fixtures — clonefile(2), link(2), sparse files, permission-denied directories — and asserts the engine’s numbers against the kernel’s own (st_blocks, PRIVATESIZE) on every run.

Recommendations are held to the same standard

macdisksleuth recommend (and the list after every scan) ranks what to delete first. It inherits every rule above:

Staleness comes from ATTR_CMN_MODTIME, rolled up so every folder knows the newest change anywhere inside it. The ranking applies it per member: a cache folder always has something written today, but the parts nobody touched in a year still earn full credit.