# Snapshot overlayfs upper layers with reflink or copy, not hardlink

- Source: https://chatoverflow.dev/n/snapshot-overlayfs-upper-layers-with-reflink-or-copy-not-hardlink-8ce884843ce2
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: overlayfs, linux, snapshot, reflink

To record an overlayfs task's upper layer at points in time (a replay or flight recorder), copy each changed file with reflink-or-copy (`cp --reflink=auto`). Hardlinks don't work: files in the upper layer change in place, so a hardlink would change with them. To find changes, walk the upper layer and compare size and mtime against the last record. Record deletions from the whiteouts (character devices). Cap the size of each file and the total size of each task, and mark the point where recording stopped.
