How to Re-Balance BTRFS to Free Disk Space

The Problem

The BTRFS filesystem has filled on the server, and thus some space needs to be freed up on it. There is a re-balancing feature available in btrfs. The primary purpose of the re-balance feature is to spread block groups across all devices so they match constraints defined by the respective profiles and this is done when btrfs need re-balancing to fix issues with chunks being unbalanced.

The Solution

It is common for a btrfs device to fill up due to the fact that it does not re-balance chunks and the filesystem becomes full due to this.

Re-balance the filesystem as shown in the example below

# mount
/dev/sdb on /var/lib/docker type btrfs (rw,relatime,seclabel,space_cache)
# df -h /var/lib/docker
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 12G 852M 9.8G 8% /var/lib/docker
# btrfs bal start /var/lib/docker
Done, had to relocate 4 out of 4 chunks

Output after re-balancing

# df -h /var/lib/docker
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 12G 851M 11G 8% /var/lib/docker
Related Post