First of all, don’t use df
on btrfs
, because it won’t give you the correct numbers due to btrfs
using copy-on-write and inline compression. Use “btrfs filesystem
” instead. See…
man btrfs-filesystem
Note: The man
pages for btrfs
are all composed of two words connected with a hyphen, but the command to use at the shell prompt is “btrfs
” with the second word as an independent parameter.
Secondly, the scenario you’re describing is the result of the way btrfs
allocates space. It divides the available space in “zones” of — I believe — 1 GiB. This can then under certain circumstances indeed lead to the available number of free extents and/or inodes
within a zone to max out while you still have ample space on your drive.
The solution is to balance the filesystem, for which there is the command “btrfs balance
” — see…
man btrfs-balance
Again, there is a hyphen in the name of the command for viewing the man
page, but the command at the prompt is without the hyphen.
NAME
btrfs-balance - balance block groups on a btrfs filesystem
SYNOPSIS
btrfs balance <subcommand> <args>
DESCRIPTION
The primary purpose of the balance feature is to spread block groups across all devices so they match constraints defined by the respective profiles. See mkfs.btrfs(8) section PROFILES for more details. The scope of the bal‐
ancing process can be further tuned by use of filters that can select the block groups to process. Balance works only on a mounted filesystem. Extent sharing is preserved and reflinks are not broken. Files are not defrag‐
mented nor recompressed, file extents are preserved but the physical location on devices will change.
The balance operation is cancellable by the user. The on-disk state of the filesystem is always consistent so an unexpected interruption (e.g. system crash, reboot) does not corrupt the filesystem. The progress of the balance
operation is temporarily stored as an internal state and will be resumed upon mount, unless the mount option skip_balance is specified.
[...]