Copy-on-write initially shares storage and copies the necessary portion when private modification requires it. It defers copying costs, with page-based process memory and private file mappings providing important examples.
Linux fork gives a child a distinct virtual address space without immediately copying every page’s contents. Parent and child can initially share physical pages, with private writes obtaining separate storage as needed.
This preserves the isolation of ordinary private modifications. Sharing the initial physical representation does not make later private writes visible as shared variables in the other process.
Page tables and protection let the kernel recognize writes requiring handling. A page fault need not be a program error: Linux documents copy-on-write as one legitimate fault-handling case.
Fork still creates task state and duplicates page-table metadata. Later writes across many pages can add copying and memory costs, so benefits depend on the subsequent workload.
MAP_PRIVATE creates a private copy-on-write file mapping. Its updates are not written back to the underlying file or exposed as those updates to other processes mapping it; MAP_SHARED has different semantics.
This is not automatically a durable snapshot. Visibility of subsequent changes to the underlying file has specified limits, and applications still need explicit consistency and persistence policies.