How Does a Copy-on-Write File System Work?

Storage server with several drive bays and two technicians examining the hardware

How Does a Copy-on-Write File System Work? Explainer

A copy-on-write file system updates stored data by writing changed blocks to new locations instead of overwriting the currently referenced blocks in place. When an application changes part of a file, the file system allocates fresh space, writes the revised data there, and builds updated metadata that points to the new block. Once the related changes are ready, it switches a higher-level pointer or commits a transaction so the new tree becomes authoritative. The old blocks remain untouched until the file system knows that nothing still references them.

This approach extends from file contents to metadata. Directories, allocation records, checksums, and tree nodes may also need new copies as pointers change toward the root. A small update can therefore cause several related blocks to be written. Transaction boundaries matter because the file system must not expose a root that points to only half of a completed change. Designs such as Btrfs organize metadata in trees and delay reusing blocks freed by the active transaction until that transaction commits. Checksums can then help detect whether data or metadata arrived corrupted, though redundancy is still required if the system is expected to repair damage rather than merely report it.

Snapshots are a natural consequence of shared references. At the moment a snapshot is created, the original and snapshot can point to the same unchanged blocks rather than copying every byte. If either version changes later, the new content is written elsewhere and only that branch of the metadata tree receives new pointers. Reflink copies apply the same idea to files: two separate file entries can share extents until one is modified. This makes snapshots and large copies fast and space-efficient when most data remains unchanged.

Copy-on-write is not the same as a backup. A snapshot that shares the same drives also shares exposure to device failure, controller faults, theft, and destructive administrative mistakes. If the underlying copy of a shared block is damaged and no redundant good copy exists, every snapshot referencing it is affected. Snapshots can preserve earlier logical states and support consistent backup creation, but durable protection still requires independent copies, tested recovery, and suitable redundancy.

Crash consistency depends on the complete write and flush protocol, not only on placing data in a fresh block. The file system must ensure that newly referenced blocks are durable before publishing a root that points to them, and it must preserve an older usable root until the new transaction is committed. Storage devices and controllers need to honor ordering and cache-flush commands for that promise to hold. After deletion or snapshot removal, the file system also has to determine when shared extents have no remaining references before reclaiming them. On solid-state storage it may later inform the device that freed ranges are unused, but logical reclamation, physical erasure, and secure deletion are different processes. Recovery tools therefore need to understand transaction roots and reference metadata rather than assuming that the newest physical block is automatically authoritative.

The design also introduces tradeoffs. Repeated small overwrites can scatter new extents around the storage device, increasing fragmentation. Metadata updates, reference counts, checksums, and background space reclamation consume work. A nearly full volume may struggle to find room for both new data and the metadata needed to complete a transaction. Some workloads, such as frequently rewritten database files or virtual-machine images, may need special allocation settings or careful tuning. Copy-on-write file systems exchange in-place simplicity for transactional updates, efficient sharing, snapshots, and stronger opportunities to verify stored data. Their reliability depends on sound hardware, enough free space, correct flush ordering, and backups that live beyond the file system itself.

A copy-on-write file system writes changed data and metadata into new blocks, then switches pointers to the new version. Key terms include COW, extent, tree root, transaction, checksum, snapshot, subvolume, reflink, reference count, fragmentation, and write amplification.

A new snapshot initially references the same unchanged blocks as its source. When either version changes, only the affected data and metadata paths are copied to new locations. Shared blocks remain until every reference to them is removed.

Copy-on-write can increase fragmentation, metadata traffic, reference-count work, and space pressure during heavy updates. Snapshots also are not independent backups. Administrators still need free-space monitoring, suitable workload tuning, redundancy, and separate recovery copies.

Explore more "Explainers"

Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.