Copy-on-Write
conceptWhen an ordinary system saves a change, it writes the new version on top of the old one, right where it sat. That's the obvious approach, and it carries a hidden bet: that nothing goes wrong mid-write. Lose power at the wrong instant and the old version is half-destroyed while the new one is half-written—the ugly middle that older systems needed repair tools for.
Copy-on-write is ZFS's refusal to ever make that bet: existing data is never written over. Ever. When you "change" a file, ZFS writes the new version onto fresh, empty space, and then—in one clean, instant switch— makes it the official one. So at every moment, what's on disk is some complete, correct state. A change either fully happened or never happened; there is nothing half-done to repair, which is why no repair pass exists.
You feel CoW everywhere before you can name it:
- Snapshots are instant and free—old blocks were never going to be overwritten, so "keep the past" is just "don't garbage-collect these yet."
- Power loss stops being scary—pull the plug mid-write; on import the pool is simply at the last committed moment. No repair pass.
- Free space is a working resource—even overwrites and deletions need fresh space to land, which is why a nearly-full CoW pool degrades (see The Free-Space Discipline).
- Sequential writes fragment over time—rewrite the middle of a file and the new blocks live elsewhere; the file's layout scatters. The steady state of a busy CoW pool is honest fragmentation managed by caching.