APFS Copy-on-Write Deduplication: Free Up Space Without Deleting Files
The Silo Team · 7 min read · September 22, 2026
What is APFS Copy-on-Write Cloning?
Traditional duplicate file finders force a destructive choice: keep one copy and delete the rest. This breaks paths, disrupts build systems, and can corrupt project references.
APFS (Apple File System) offers a fundamentally different approach. Using the Darwin clonefile(2) system call, two files can share the exact same physical disk blocks — while still appearing at their original paths with full read/write access. This is called Copy-on-Write block sharing.
How clonefile(2) Works Under the Hood
When MacPilot calls clonefile(2) on a pair of duplicate files:
- The filesystem creates a new directory entry pointing to the same B-tree extent nodes as the original.
- Both files remain accessible at their original paths.
- The physical disk blocks are not duplicated — they are shared.
- Only when one copy is modified does the filesystem allocate new physical blocks for the diverging data (Copy-on-Write semantics).
The result: instant space reclamation with zero data loss and zero path changes.
Where This Matters Most for Developers
- Ollama model weights: LLM models stored in multiple hub directories (Ollama + LM Studio + HuggingFace) are often byte-identical.
- Node module copies: Different projects often install identical package tarballs.
- iOS Simulator runtimes: Multiple simulator runtimes share many identical system libraries.
- Build artifacts: Xcode reuses many object files between builds that may be identical across targets.
What MacPilot Does Differently
Most duplicate finders use SHA-256 hashing to find matches. MacPilot does too — but it then applies clonefile(2) instead of deleting. It also:
- Skips cloud-synced stubs that would trigger downloads on hash read.
- Respects SIP-protected system files.
- Verifies both files are on the same APFS volume (required for clonefile).
- Shows you projected savings before committing.
Keep reading
How to Free Up Disk Space on Mac: The Developer's Complete Guide
From APFS clone-aware deduplication to DerivedData nukes and Docker.raw shrinking — the most complete storage reclaim guide for macOS engineers.
Why Deleting ~/Library/Caches Slows Down Your Mac: The Stale-Aware Cache Guide
Standard Mac cleaners blindly purge ~/Library/Caches, triggering the infamous 'post-cleanup stutter' where apps redownload hundreds of MBs of avatars and shader caches. Here is how Stale-Aware Cache Eviction keeps your Mac fast while freeing tens of gigabytes.