Course contentsShow
← Computer Science
Lesson 1408 of 2,87232. File SystemsFree lesson

Copy-on-Write File Systems

Study CoW strategies that never overwrite data in place, enabling snapshots and transactional updates.

Copy-on-Write File Systems

What you'll learn: How CoW file systems achieve snapshots and atomic updates by never modifying data in place.

The Core Idea

A Copy-on-Write (CoW) file system never overwrites existing data blocks. Instead, when you modify a file, the system writes the new version to a fresh location on disk, leaving the original intact. Only after the write succeeds does the system update metadata pointers to reference the new data.

This is fundamentally different from traditional file systems that update blocks in place, which can leave data corrupted if a crash occurs mid-write.

How It Works

Think of it like editing a book with sticky notes. Instead of erasing and rewriting pages, you write the new version on blank pages and update your table of contents. The old pages stay exactly where they are until you decide you no longer need them.

The CoW Write Process:

  1. Application requests a change to a file block
  2. File system allocates a new free block
  3. Modified data is written to the new block
  4. Metadata pointers (inode, indirect blocks) are updated to point to the new block
  5. Old block is marked as free (eventually reclaimed)

Key Benefits

Snapshots: Since old data isn't destroyed, you can keep references to previous versions essentially "for free" — just don't reclaim those blocks. The entire file system state at any moment becomes a snapshot.

Transactional consistency: Either a write completes fully (new blocks written, metadata updated) or it doesn't happen at all. No partial writes, no corruption.

Efficient cloning: Creating a copy of a file just means duplicating metadata pointers — no actual data copying until modifications occur.

Key Takeaway: Copy-on-Write file systems trade some write performance overhead for powerful guarantees: instant snapshots, crash consistency, and the ability to maintain multiple versions of data with minimal storage cost until blocks actually diverge.