{
  "slug": "btrfs-balance",
  "term": "Btrfs balance",
  "aliases": [
    "btrfs balance"
  ],
  "definition": "Btrfs balance relocates selected block groups on a mounted filesystem according to allocation-profile constraints.",
  "note": "Balance preserves shared extents; it neither defragments nor recompresses files. Filters can select groups for compaction or profile conversion. [balance-intro]\n\nRelocation usually needs a new block group before releasing the old one. Its workspace ENOSPC is therefore distinct from exhausted file space. The usage=0 case reclaims entirely unused groups without allocating that workspace, but is not a guaranteed remedy for every ENOSPC. [balance-workspace]\n\nIn btrfs filesystem df, total is capacity already allocated to a block-group type/profile and used is occupied space within it. Their difference is not device-unallocated workspace. File defragmentation can break reflinks and increase allocation; balance preserves sharing. [filesystem-space]\n\nScrub checks checksums and read errors, with repair dependent on known-good replicas. It is not a full filesystem checker; NODATASUM file payload lacks data-checksum validation. Read-only scrub on a read-write filesystem can still cause filesystem writes; the documented no-write combination requires both read-only scrub and a read-only filesystem. This is a mount-mode boundary, not a claim that every checksum scan is write-free. [scrub-scope]\n\nThe design paper explains sharing-preserving relocation through back references and copy-on-write relocation trees, merged with active trees after pointer updates. Its historical benchmarks do not establish a present-day balance speedup. [btrfs-design-paper]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Selective compaction can release block-group allocation while retaining shared file extents.",
      "citationIds": [
        "balance-intro",
        "balance-workspace"
      ]
    }
  ],
  "limitations": [
    {
      "text": "An unfiltered balance can move data and metadata across the filesystem and compete with applications for I/O.",
      "citationIds": [
        "balance-intro"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-30",
  "related": [
    "btrfs",
    "filesystem-defragmentation",
    "free-space-fragmentation",
    "data-scrubbing",
    "reflink"
  ],
  "citations": [
    {
      "id": "balance-intro",
      "title": "Btrfs-progs v6.16: balance purpose, extent sharing and I/O costs",
      "url": "https://raw.githubusercontent.com/kdave/btrfs-progs/v6.16/Documentation/ch-balance-intro.rst",
      "accessed": "2026-11-29"
    },
    {
      "id": "balance-workspace",
      "title": "Btrfs-progs v6.16: balance ENOSPC and empty-block-group exception",
      "url": "https://raw.githubusercontent.com/kdave/btrfs-progs/v6.16/Documentation/btrfs-balance.rst",
      "accessed": "2026-11-29"
    },
    {
      "id": "filesystem-space",
      "title": "Btrfs-progs v6.16: filesystem df allocation counters and defragmentation",
      "url": "https://raw.githubusercontent.com/kdave/btrfs-progs/v6.16/Documentation/btrfs-filesystem.rst",
      "accessed": "2026-11-29"
    },
    {
      "id": "scrub-scope",
      "title": "Btrfs-progs v6.16: scrub verification, replica repair and NODATASUM limits",
      "url": "https://raw.githubusercontent.com/kdave/btrfs-progs/v6.16/Documentation/ch-scrub-intro.rst",
      "accessed": "2026-11-29"
    },
    {
      "id": "btrfs-design-paper",
      "title": "Rodeh, Bacik and Mason (2013): BTRFS, Section 5 (author manuscript)",
      "url": "https://www.researchgate.net/publication/262177144_BTRFS_The_Linux_B-Tree_Filesystem",
      "accessed": "2026-11-29"
    },
    {
      "id": "hesela-aging",
      "title": "Hesela: filesystem aging, allocation geometry and Btrfs maintenance boundaries",
      "url": "https://hesela.com/analyses/filesystem-aging-free-space-fragmentation/",
      "accessed": "2026-11-29"
    }
  ],
  "provenance": [
    "Source review of btrfs-progs v6.16 documentation, accessed 2026-11-29; not a native filesystem experiment or performance measurement.",
    "Kernel and tool versions, allocation profiles and device layout remain relevant to an actual maintenance plan.",
    "Historical mechanism checked against the author manuscript, Section 5; DOI 10.1145/2501620.2501623. Operational statements remain scoped to btrfs-progs v6.16 documentation."
  ]
}
