Pcornel
Storage · Filesystems

Btrfs

Cheat sheet · https://pcornel.dk/topic.php?topic=3952

Back to the Topic

Answer

Btrfs uses copy-on-write B-trees for metadata and data extents, maintains checksums, and allocates space through chunks/block groups. Logical free space, device free space and metadata/data allocation can therefore diverge.

Remember

  • Btrfs snapshot ≠ independent backup.
  • Checksum error ≠ automatic repair without another valid copy.
  • df free space ≠ complete Btrfs allocation picture.
  • Btrfs RAID profile ≠ traditional RAID implementation semantics in every case.

First checks

  • btrfs filesystem usage <mount> — allocation (data/metadata)
  • btrfs device stats <mount> — error counters
  • btrfs scrub status <mount> — scrub result

Verify in this order

file → COW B-trees → chunks → devices

Where it usually breaks

First mismatch in media/provider → controller/pool → logical object → path/protocol → filesystem/share/object namespace → consumer workload; preserve identity/pre-state before mutation.

Filesystems → Btrfs filesystem map

Filesystem boundaryWhat to verifyProof limit
Identity / attachmentFilesystem type, source/backing object, mount/attachment target and effective optionsPresence or mount state alone does not prove consistency or lower-layer health
Capacity / metadataData space, metadata/inodes, quotas/reservations and filesystem stateFree bytes at one layer do not prove allocation can succeed end to end
Failure boundaryA mounted Btrfs filesystem proves current logical access; it does not prove every checksum is validated, redundant repair copies exist or allocation pressure is absent.Correlate filesystem evidence with the backing volume/path/backend before repair
AcceptanceHealthy evidence: expected devices and profiles are present, data/metadata space is available, scrub/checksum state is clean and representative reads/writes succeed.Close only after the original path/workload and read-back check succeeds

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3952

Confirmation

Confirm action

Continue?