If you use a 256 GB or 512 GB MacBook, you eventually run into the "Your disk is almost full" wall. Most Mac cleaners solve this by deleting caches and logs, or charging a subscription to show you big folders.
I wanted something different: a free, open-source tool that reclaims real space from the files I actually want to keep, without deleting a single file or re-encoding photos and videos.
So I built ketodisk in Rust.
How it shrinks files without changing a single byte
macOS APFS already has strong space-saving primitives built into the filesystem, it just rarely applies them to existing user files on its own. Existing open-source tools like afsctool or ditto --hfsCompression only handle one piece of the puzzle.
ketodisk puts three native APFS mechanisms behind one cost planner:
- Exact duplicate CoW cloning (
clonefile): If you have identical copies of a file across folders, APFS can point both entries at the same physical blocks on disk. If the file is also compressible,ketodiskcompresses once so the clones share the compressed extents. - Native transparent LZFSE compression (
com.apple.decmpfs): macOS supports transparent filesystem compression using Type 11 inline extended attributes (for small files) and Type 12 resource forks withUF_COMPRESSED(for larger files). Finder, Spotlight, and your apps keep reading everything normally. There are no.ziparchives to unpack. - Fixed-offset 4 KiB near-duplicate block sharing: Unlike Btrfs or XFS on Linux, APFS does not expose
FICLONERANGEfor arbitrary block-range deduplication. For large similar files (append-only logs, datasets, page-modified images),ketodiskclones a base file and selectively overwrites only the differing 4 KiB blocks when that saves more space than compressing each file independently.
Architecture and chasing a 30x speedup
The core planner, scanner, and CLI are written in Rust, paired with a small C shim compiled directly against the macOS SDK headers. Using a thin C layer meant I did not have to hand-maintain fragile struct layouts for getattrlist, decmpfs, and proc_listpidspath.
Early prototypes crawled at around 2.3 MiB/s on cold trees with lots of small files because of per-file syscall and staging overhead. After reworking the staging pipeline and parallelism, throughput jumped to ~70 MiB/s on Apple Silicon (a 1,000-file synthetic tree finishes end-to-end with full hash verification in roughly 3.3 seconds).
Why it won't corrupt your files
Modifying user files in place is high stakes, so the entire pipeline is preview-only by default and fail-closed on every write:
- Strict skipping: Automatically skips
SF_DATALESSiCloud placeholders (so scanning will never accidentally trigger massive iCloud downloads),.appbundles, hardlinks, immutable files, and active SQLite WAL/SHM file sets. - Verified atomic swaps: Before replacing any file,
ketodiskstages a temp copy, reads it back to verify the full SHA-256 hash matches byte-for-byte, checksproc_listpidspathfor other processes holding the file open, swaps viarenamex_np(..., RENAME_SWAP), and runs a post-swap verification before unlinking the displaced copy. - Fault-injection testing: The test suite has 55 tests, including 24 live APFS fault-injection tests covering mid-stage aborts, open-FD races, modification drift rollbacks, and journaled crash recovery (
ketodisk doctor --clean-temp).
Honest caveats
No disk tool is magic, and it helps to be upfront about the limits:
- Live databases and active VMs: APFS returns
ENOTSUPforexchangedata(2). From unprivileged user-space, there is still an irreducible race if another process already holds a writable file descriptor ormmapandproc_listpidspathis restricted. Everything is documented inSECURITY.md, and you should not runketodiskon active databases or running VM images. - Already-compressed media: MP4s, JPEGs, and ZIP archives will not shrink much further (unless you have exact duplicates).
- 1-byte shifts: Fixed-offset 4 KiB matching breaks if data shifts by a byte; the planner detects this and falls back safely.
- Finder free-space lag: If you use Time Machine, local APFS snapshots hold onto old blocks until macOS prunes them (usually within 24 hours), so Finder may not reflect the reclaimed gigabytes immediately.
Try it safely on dummy files
You can install it via Homebrew (built from public source, MIT licensed, zero telemetry):
bash brew install subwaycookiecrunch/tap/ketodisk 

