Analyses / Filesystem recovery
Btrfs tree logs: why a read-only mount can still replay writes
Published 15 October 2026 / Updated 15 November 2026 / Version-pinned source review
Read-only is not a complete description of Btrfs recovery behavior. Mount-time tree-log replay can write even when the requested mount is read-only. Skipping replay changes the recovered view; clearing the log changes the evidence. These are different operations, not interchangeable repair steps.
On this page9 sections
Copy-on-write still has a recovery log
Btrfs uses copy-on-write metadata, but an fsync need not commit the whole filesystem transaction. The Linux v6.16 design comment describes a tree log per subvolume root: changed items for a file or directory can be logged separately. Recovery later incorporates those items into the subvolume tree and accounts for their data extents. [1]
Bacik's 2012 architectural explanation describes why limiting the metadata involved in fsync can avoid unrelated work. That is historical design context, not a latency guarantee for today's systems. [8] The v6.16 fsync implementation still includes a full transaction-commit fallback. Neither "fsync always commits everything" nor "fsync only ever writes the log" is a sound rule. [2]
Our interpretation: a crash-recoverable file update and a fully committed filesystem transaction are different boundaries. Treating them as one event can make a recovery procedure discard information the application expected to survive. The analogous distinction in ZFS intent logging does not imply identical on-disk formats or recovery algorithms.
The mount itself is part of the write boundary
Btrfs documents replay on read-only mounts. Its rescue option rescue=nologreplay suppresses dirty-log replay and requires a read-only mount. Files or directories represented only by the pending log may consequently be absent from that view. A readable older view does not prove that acknowledged updates never existed. [3]
This also qualifies read-only scrub advice: the scrub operation and the earlier mount are separate stages. "The scrub did not repair anything" cannot establish that mounting left the original image untouched. For an investigation, preserve the source and work from a controlled copy; record the recovery policy before interpreting missing content.
Which layer is read-only?
The same label can describe three different controls. Record the object and layer before treating a read-only observation as evidence about storage preservation.
| Control | Scope | What it does not establish |
|---|---|---|
| Btrfs subvolume ro | A property of one subvolume's contents and hierarchy. [10] | Neither a device-wide lock nor a change to the mount flags. |
| Read-only mount | Linux distinguishes the VFS mount node from the filesystem superblock. A requested ro setting applies to both layers by default for standard mounts. [12] | A read-only bind mount can coexist with a writable original path. |
| Block-device read-only flag | Software-controlled device state, exposed through ioctls. [13] | The util-linux v2.41.1 manual warns that existing active access may be unaffected, including a filesystem already in read-write use. |
A read-only access path does not turn a writable Btrfs subvolume into a read-only subvolume. Conversely, a read-only subvolume does not freeze the entire filesystem. Its property and the mount state answer different questions. [11] The tree-log replay boundary above remains a separate part of recovery.
The optional spellings have a compatibility boundary. The v2.41.1 manual dates ro=vfs and ro=fs to util-linux 2.41, labels these arguments experimental, and requires the file-descriptor-based kernel mount API. With the old mount(2) interface, the argument is silently ignored. [12, ro option] Do not infer the resulting layer from the requested spelling alone. The non-mutating query findmnt -o TARGET,VFS-OPTIONS,FS-OPTIONS separates the reported flags; it does not prove an absence of device writes.
There is also a coverage trap: Btrfs snapshots are non-recursive. Nested subvolume contents are omitted from the parent snapshot, leaving stubs. [11] For example, a parent containing a separately created database subvolume does not capture that database merely because its pathname is beneath the parent. This is an illustrative consequence, not an experiment. Compare snapshot and backup failure boundaries.
Identify the device behind the path
A block device is an operating-system abstraction, not necessarily a physical drive. In Linux, S_IFBLK identifies a block special file. Its st_rdev identifies the represented device; st_dev identifies the device associated with the node's containing filesystem. Confusing these fields can associate an observation with the wrong layer. [24]
A loop device can map blocks to a regular file or another block device. A filesystem image may therefore sit behind both a loop mapping and a backing filesystem. Record that backing relationship alongside the node being inspected; a pathname alone does not describe the storage stack. Linux permits LOOP_CHANGE_FD only for a read-only loop device whose replacement backing store matches the old store in size and type. Consequently, an unchanged device node is not proof of an unchanged backing image. [25] Nor does a block interface imply nonvolatile media: zram stores compressed pages in RAM, with optional writeback to a configured backing device. [26]
For recovery, the practical recommendation is to keep device identity, backing storage, effective write restrictions and filesystem replay policy separate. The block-device label alone establishes neither power-loss persistence nor a validated write-blocking configuration. The existing active-access warning for the read-only flag still applies. [13] [14]
A different mount view can reach the same data
A Linux mount namespace separates the mount list seen by its processes; creating one copies that list, not the file contents. Shared-subtree propagation can still carry mount and unmount events across namespaces. Namespace separation alone therefore proves neither independent data nor a private mount topology. [20] [21]
A bind mount exposes an existing file or subtree through another path. Ordinary binding excludes nested mounts; recursive binding includes eligible submounts but prunes unbindable subtrees. [22] A read-only bind path can still observe changes made through another writable path. It is an access restriction, not a snapshot. [12]
For inspection, record the target process and its mount view alongside the access flags. /proc/PID/mountinfo separates per-mount options from superblock options and exposes propagation fields. Reading the investigator's own view is not sufficient to establish what the target process sees. [23] None of these observations removes the Btrfs replay boundary described above.
Mount propagation is directional, not a synonym for namespace isolation. A shared mount exchanges events with its peer group; a slave receives from its master group without sending events back upstream, and can also share with its own peer group. Private mounts do not exchange propagated events. This policy concerns mount topology, not copies of file contents. [21]
Inspect the optional shared:N and master:N fields separately from ro/rw. Both tags can appear on a shared-and-slave mount; a private mount has none of the recognized propagation tags. [23] Changing only the top mount to private does not change every descendant: propagation applies to events immediately beneath each mount, and recursive changes are explicit. [20] Our synthesis: isolation of mount events does not freeze reachable data or prove that another access path cannot write. [12]
Distinguish the system call from the command-line tool. Since util-linux 2.27, unshare makes propagation recursively private by default when creating a mount namespace; --propagation unchanged disables that extra step. The syscall alone does not supply this command policy. Record the entry point and options before comparing observations. [20, notes]
Our preservation conclusion is deliberately narrower than "read-only means safe": none of these flags alone validates an entire forensic write-blocking workflow. Software is not inherently disqualified; NIST maintains software write-blocker testing resources. [14] Identify the exact configuration, prior access and recovery policy, and preserve the source before drawing conclusions from a working copy.
Read-only images: format, access and trust
EROFS and SquashFS are read-only filesystem formats for prepared images. This differs from mounting a writable filesystem with ro: an access setting does not replace its recovery design. The Btrfs replay warning above must not be generalized into a claim that every read-only filesystem replays a journal.
| Image format | Layout and qualification |
|---|---|
| EROFS | mkfs.erofs prepares images with uncompressed or compressed file-data layouts, including inline tails and fragments. [15] Compression is optional; tail packing is not unique to SquashFS. |
| SquashFS | mksquashfs prepares images with file-data and metadata compression, plus fragment blocks for file tails. [16] Metadata blocks may be uncompressed by request or when compression would enlarge them. The format name does not mean every block is compressed. |
Successful mounting or decompression does not authenticate an image. For a block-backed deployment, dm-verity checks accessed blocks against a trusted root hash. That root and the mapping parameters need their own trusted provenance. Verification is on demand, so a successful read does not mean the entire image has been checked; ignore_corruption can also allow access after a mismatch. [17]
The same block-size label can measure different bytes
Gao and colleagues' ATC 2019 EROFS design fixes the compressed output size while the represented uncompressed extent varies. Its Android 9 / Linux 4.14 evaluation is historical evidence, not a ranking of today's builds. [18, sections 3.1 and 5.1] Linux v6.16 documents larger physical clusters since v5.13: the original 4 KiB output is not a permanent format limit. [15]
Huang and colleagues' FAST 2026 RubikFS study makes the comparison trap explicit: its EROFS and RubikFS block sizes describe compressed bytes, whereas SquashFS sizes describe input bytes. Equal labels therefore do not equalize the amount of original data represented. RubikFS groups similar chunks and separates hot from cold data before compression. [19, sections 4 and 6.1]
Its compression study covers six images, but the read-amplification experiment uses openEuler, 1 MB blocks and constructed 12%/40% hot-data traces under FEMU emulation. Those traces select hot files and pages; they are not six measured production startup traces. [19, sections 6.1 and 6.4] Our comparison rule: record input versus output units, codec, cache state, access pattern and actually read bytes alongside image size. A smaller image alone does not establish cheaper random reads. We have not reproduced either paper's benchmark.
Our practical synthesis: record the image format and enabled features, reader compatibility, effective access policy and verification configuration separately. Neither compactness nor read-only access answers all four questions. Keep the build settings when comparing images; this source review supplies no performance ranking. See also identity and freshness limits of checksums.
The old option spelling stopped working upstream
The Btrfs feature history places rescue= in Linux 5.9 and removal of standalone nologreplay in 6.16. [4] We compared the option-registration tables in the two adjacent upstream tags. This resolves an important trap: rolling documentation can still mention a legacy spelling even though a newer parser no longer registers it. [9] [5]
| Upstream tag | Standalone nologreplay | rescue=nologreplay | norecovery alias |
|---|---|---|---|
| v6.15 | Registered, deprecated | Registered | Registered for compatibility |
| v6.16 | Not registered | Registered | Registered for compatibility |
notreelog controls tree logging; it is not the switch for skipping an existing recovery log. In v6.16, it sets NOTREELOG, while the rescue replay option sets NOLOGREPLAY. The broader rescue=all also enables options that ignore checksum checks: it is not an equivalent shorthand. [5]
Download the source-audit JSON with SHA-256 hashes and audit script. Running node audit-btrfs-options.mjs fetches the pinned source files and prints the comparison. The script checks exact table boundaries and fails if its expected structure changes. It does not compile a kernel, mount a volume, or certify runtime behavior.
Skipping replay is not clearing the log
btrfs rescue zero-log clears the on-disk log tree. The tool documentation warns that changes since the last transaction commit may be lost. That is a destructive recovery action, not merely another way to inspect a filesystem without replay. [6]
Consider a file whose update was made recoverable through the tree log before a crash. If replay is deliberately suppressed, failure to see that update is not by itself an fsync failure. If the log is then cleared, the recovery input is removed. This is a reasoning example derived from the documented boundaries, not an experiment we ran.
We provide no repair command sequence for an unknown damaged volume. Establish whether the objective is preserving evidence, recovering the newest valid state, or inspecting an earlier state. A successful mount alone cannot decide which objective was met.
What crash-testing research adds
Mohan and colleagues' OSDI 2018 study used CrashMonkey and Ace to generate bounded workloads and simulate crashes around persistence points. New-bug testing used Linux 4.16; shorter sequences covered ext4, XFS, F2FS and Btrfs, while the larger three-operation search focused on F2FS and Btrfs. Those populations were not identical. [7, section 6.2]
One reported Btrfs rename-atomicity failure required an fsync on a sibling file before the crash, illustrating a non-obvious interaction. It is a historical counterexample, not evidence that Linux 6.16 has that bug. Nor does finding no bug within a bounded search prove correctness outside it. [7, section 6.2]
The test device is itself an abstraction: CrashMonkey records writes through a wrapper over an in-memory block device and builds writable snapshot images. It allows normal recovery before comparison with an oracle captured after a safe unmount. The published bounded method does not explore reordered I/O or crashes inside a filesystem operation. [7, sections 4.4 and 5.1] Our interpretation: this is a recovery-contract test, not a hardware write-blocker test; deliberately skipping replay would change the contract being checked.
For a future disposable experiment, our proposed oracle would distinguish normal replay from intentionally skipped replay and compare application-visible names, contents and link relationships. Record return values, kernel build, filesystem features and the exact crash point. Do not label deliberately omitted recovery as a filesystem durability defect. See crash-test oracles and bounds.
Method and limits
This is a documentation and code review, with an executable source-registration audit. No filesystem was mounted, repaired or power-cut. We measured no latency, write amplification or failure rate. Version-pinned implementation details do not promise identical behavior in vendor kernels, and a rescue option is not a full forensic write-blocking strategy.
Related mechanisms: ext4 revocation and interrupted replay, failed fsync and retries, and checksums versus freshness.
Primary sources
- Linux v6.16: Btrfs tree-log.c, design comment and replay implementation
- Linux v6.16: Btrfs file.c, btrfs_sync_file and transaction-commit fallback
- Btrfs documentation: btrfs(5), tree logging and rescue mount options
- Btrfs feature-by-version: rescue in 5.9 and standalone nologreplay removal in 6.16
- Linux v6.16: Btrfs super.c, option registration and read-only checks
- Btrfs documentation: btrfs-rescue(8), zero-log and possible loss of changes
- Mohan, Martinez, Ponnapalli, Raju and Chidambaram (2018). Finding Crash-Consistency Bugs with Bounded Black-Box Crash Testing. OSDI 18, pp. 33-50, sections 5-6.
- Josef Bacik (2012). Btrfs: The Swiss Army Knife of Storage. USENIX ;login:, volume 37, number 1, Filesystem Consistency section.
- Linux v6.15: Btrfs super.c, deprecated standalone nologreplay registration
- Btrfs documentation: subvolume ro property
- Btrfs documentation: subvolume flags and non-recursive snapshots
- util-linux v2.41.1: mount(8), Read-only Setting Notes
- util-linux v2.41.1: blockdev(8), read-only flag and active-access caveat
- NIST CFTT: Software Write Block testing resources
- Linux v6.16: EROFS overview and on-disk data layouts
- Linux v6.16: Squashfs 4.0 image creation and filesystem design
- Linux v6.16: dm-verity trust, on-demand checks and failure policies
- Gao, Dong, Miao, Du, Yu and Chen (2019). EROFS: A Compression-friendly Readonly File System for Resource-scarce Devices. USENIX ATC 19, pp. 149-162, sections 3.1 and 5.1.
- Huang, Zhang, Pan, Xia, Zou, Yang, Zhong and Liao (2026). Towards Condensed and Efficient Read-Only File System via Sort-Enhanced Compression. FAST 26, sections 4, 6.1 and 6.4.
- Linux man-pages: mount_namespaces(7), namespace creation and mount-list scope
- Linux man-pages: mount(2), bind, recursive bind and per-mount remount flags
- Linux man-pages: proc_pid_mountinfo(5), per-process view and option layers
- Linux man-pages: inode(7), file type and represented-device identity
- Linux man-pages: loop(4), file-backed and block-backed loop devices
- Linux 6.12: zram, compressed RAM backing and optional writeback
Read-only image comparison reviewed 23 October 2026. Rolling manuals are distinguished from pinned source tags.