Skip to content

Quotas and Qgroups

Chapter 5 noted the trap: subvolumes have no size of their own, so one greedy subvolume can fill the whole filesystem. This chapter fits the counterweight — quotas, in btrfs called qgroups — and is honest about their price. The outcome: a size limit on a subvolume, a report of what each subvolume holds, and a clear-eyed choice about whether the bookkeeping is worth it on your system. Quotas are a mounted-filesystem feature and could not be run in the lab (transcript t00); documented-only, as labelled.

Turning them on, setting a limit

sudo btrfs quota enable /mnt/data
sudo btrfs qgroup limit 20G /mnt/data/projects
sudo btrfs qgroup show /mnt/data

qgroup show is the report worth the whole chapter: one line per subvolume, its referenced bytes (everything reachable from it) and exclusive bytes (the part no other subvolume or snapshot shares — what deleting it would actually free). Those two numbers teach snapshot accounting better than any diagram: a snapshot's referenced size is the whole tree; its exclusive size is the few blocks that changed since. The limit, when a write would cross it, fails that write with a quota error rather than letting the pool drain — which is the point, and also a new error for your users to meet, so set limits with headroom.

The honest price

Qgroups make the kernel account for every block's ownership, on every write, forever. On large, busy, snapshot-heavy systems that bookkeeping has historically been a real performance cost and a source of bugs; the btrfs documentation itself has long advised enabling quotas only when you need them. The measured middle path:

  • Small system, a handful of subvolumes, a real need to fence one of them: quotas on, enjoy the reports.
  • Big archival system with hundreds of snapshots: leave quotas off, and watch the pool itself (btrfs filesystem usage) instead of pretending per-tree numbers are exact.
  • Never enable quotas during an emergency. The initial scan of a large filesystem (a rescan) is exactly the work a sick system cannot spare.

A lighter cousin exists for simple cases: btrfs qgroup accounting is also what some snapshot tools use just to report sizes, enabled temporarily. But a limit enforced only sometimes is not a limit, and this guide would rather tell you the tool is heavy than pretend it is free.