A copy-on-write file system is a file system that never overwrites data in place: when a block changes, the new version is written to a free location and the metadata pointers are then updated to reference it. In operating systems and OS storage, this design underpins ZFS, Btrfs, APFS and ReFS, and it is the foundation of cheap snapshots, clones and end-to-end checksums.
Because the old block stays intact until the new one is safely committed, the on-disk structure moves from one consistent state to the next in a single atomic step. That property replaces much of what a journaling file system achieves with a separate log.
How copy-on-write updates data
Copy-on-write, often abbreviated CoW, treats the file system as a tree of blocks whose root points to directories, files and data. A change at the bottom of that tree triggers new copies all the way up, a pattern known as shadow paging or the wandering tree.
- The application modifies part of a file, and the new data is written to unallocated blocks.
- The parent metadata block that points to the old data is itself copied and updated to point to the new block.
- This continues up to the root, producing a new version of the tree that shares every unchanged block with the old one.
- Finally, the system atomically updates the root pointer, often called the uberblock or superblock, so the new tree becomes current.
If power fails before the root pointer changes, the file system simply mounts the previous tree, which is still complete and valid. There is no half-written state to repair, so a lengthy consistency check such as fsck is normally unnecessary. Writes are usually grouped into transactions lasting a few seconds to amortize the cost of updating the tree.
Features enabled by copy-on-write
Because old blocks survive until they are explicitly freed, copy-on-write makes several advanced features nearly free to implement. The table summarizes the most important ones.
| Feature | How CoW enables it | Practical benefit |
|---|---|---|
| Snapshots | Keep a reference to an older root pointer | Instant point-in-time copies of a volume |
| Clones | Create a writable tree that shares blocks | Fast copies of virtual machines or datasets |
| Checksums | Store each block’s checksum in its parent | Detects silent corruption on every read |
| Self-healing | Read a good copy from a mirror when a checksum fails | Automatic repair of damaged blocks |
| Send and receive | Compare two snapshots to find changed blocks | Efficient incremental replication |
| Reflink copies | Point a new file at existing blocks | File copies that consume no extra space |
A snapshot initially consumes almost no extra space, because it shares every block with the live file system. Space grows only as the live data diverges, since blocks referenced by the snapshot cannot be freed until the snapshot is deleted.
Copy-on-write compared with journaling and in-place designs
Copy-on-write is one of three main strategies for keeping a file system consistent across crashes. The comparison below places it next to the traditional in-place design and the journaling approach used by NTFS, ext4 and XFS.
| Approach | Crash consistency method | Snapshot support | Typical examples |
|---|---|---|---|
| In-place update | Full scan with a repair tool after a crash | None built in | FAT32, exFAT, ext2 |
| Journaling | Replays a log of pending metadata changes | External, such as volume shadow copies | NTFS, ext4, XFS, HFS+ |
| Copy-on-write | Atomic switch to a new consistent tree | Native and inexpensive | ZFS, Btrfs, APFS, ReFS |
Journaling usually protects only metadata by default, so file contents can be torn after a crash. A copy-on-write file system protects data and metadata together, because neither is overwritten. Some designs, such as ZFS with its ZFS intent log, still keep a small log to make synchronous writes fast, but the log is an optimization, not the consistency mechanism.
Copy-on-write file systems on desktop platforms
Each major desktop platform now ships at least one copy-on-write file system, although maturity and defaults vary considerably. The table lists the main implementations and where they are used.
| File system | Platform | Status | Notable traits |
|---|---|---|---|
| APFS | macOS, iOS | Default since 2017 | Clones, snapshots for updates and Time Machine |
| Btrfs | Linux | Default in Fedora and openSUSE | Subvolumes, snapshots used for rollbacks |
| ZFS | FreeBSD, Linux via OpenZFS | Mature, widely used on servers | Pooled storage, strong checksums, RAID-Z |
| ReFS | Windows Server, Windows 11 Dev Drive | Specialized use | Integrity streams, block cloning |
On macOS, APFS snapshots let the system install an update and fall back to the prior state if it fails. On Linux, distributions combine Btrfs snapshots with boot menu entries so a user can boot into the system as it was before a package upgrade.
Limitations and tuning considerations
The main cost of copy-on-write is fragmentation under random overwrites. Because every modified block lands somewhere new, a file that is repeatedly rewritten in small pieces, such as a database or virtual machine image, gradually scatters across the disk and loses sequential read performance.
- Write amplification: one small change can rewrite several metadata blocks up the tree.
- Free space sensitivity: performance often degrades sharply when a pool exceeds about 80 to 90 percent full.
- Snapshot retention: deleting files does not free space while snapshots still reference them, which surprises many users.
- Workload tuning: administrators often disable CoW per file for databases on Btrfs with the
nodatacowattribute, which also disables checksums for that file.
On solid-state drives, fragmentation matters less because random reads are fast, which is one reason copy-on-write designs became practical defaults on SSD-based desktops. Even so, sustained random-write workloads still benefit from careful record size and snapshot policies.
In everyday language
Imagine editing a document by writing every change on a fresh sheet of paper instead of erasing the old page. Only when the new page is finished do you swap it into the binder. If you are interrupted halfway, the binder still holds the complete old version.
A copy-on-write file system works the same way. Because old pages are kept, it can also save a snapshot of the whole binder in an instant and go back to it later.
Seen in the real world
A software developer runs Fedora Linux on a laptop with a Btrfs root file system. The system is configured to take an automatic snapshot before every package update, and it keeps the last ten snapshots.
One evening a graphics driver update leaves the desktop unable to start. The developer selects the previous snapshot from the boot menu, starts the system as it was an hour earlier, and rolls back the update in under five minutes. The snapshots together use only a few gigabytes, because they share all unchanged blocks with the live system. The outcome is no reinstallation and no lost files, only a postponed driver upgrade.