In this lesson, you will learn how to enforce specific disk space constraints on individual subvolumes within your Btrfs storage pool.
The Problem: Sharing Space
When you create multiple subvolumes in a single Btrfs filesystem, they all draw from the same total pool of storage. By default, a "greedy" subvolume could potentially consume all available free space on the disk, leaving nothing for your other datasets, system logs, or backups. To prevent this, Btrfs provides a Quota system that allows you to set "hard limits" on the size of individual subvolumes.
Enabling Quotas
Before you can limit a subvolume, you must enable quota tracking for the entire filesystem. Think of this as turning on the "accountant" for your storage pool. Once enabled, Btrfs begins tracking exactly how much data each subvolume is writing to the disk.
# Enable quota tracking for the filesystem at /mnt/my_btrfs
sudo btrfs quota enable /mnt/my_btrfs
Setting a Limit
Once quotas are enabled, you can restrict a specific subvolume. For example, if you have a subvolume named projects and you want to ensure it never exceeds 10 Gigabytes, you use the qgroup (quota group) command:
# Limit subvolume ID 256 to 10GB
sudo btrfs qgroup limit 10G /mnt/my_btrfs/projects
If a user or process attempts to write data to the projects subvolume that would push it over the 10GB threshold, Btrfs will return a "Disk quota exceeded" error and prevent the write.
Why Use This?
This mechanism is essential for multi-tenant environments or systems with many users. By applying these limits, you ensure that one subvolume remains isolated from the growth of another. Even though they share the same physical disks, their "logical" size is strictly controlled, preventing a runaway process from impacting the stability of the rest of your system. It turns your flexible, shared pool into a predictable storage environment where you define the boundaries for every workload.
Key Takeaway: Enabling quotas and defining qgroup limits allows you to strictly bound the storage consumption of individual subvolumes, preventing any single dataset from consuming your entire pool.