Unallocated vs free?

Why is unallocated 70.32GiB but free is 256.45GiB?

sudo btrfs fi us /

Overall:
    Device size:		 475.35GiB
    Device allocated:		 405.03GiB
    Device unallocated:		  70.32GiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			 214.67GiB
    Free (estimated):		 256.45GiB	(min: 256.45GiB)
    Free (statfs, df):		 256.45GiB
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		 512.00MiB	(used: 0.00B)
    Multiple profiles:		        no

Data,single: Size:396.00GiB, Used:209.87GiB (53.00%)
   /dev/nvme0n1p3	 396.00GiB

Metadata,single: Size:9.00GiB, Used:4.79GiB (53.26%)
   /dev/nvme0n1p3	   9.00GiB

System,single: Size:32.00MiB, Used:80.00KiB (0.24%)
   /dev/nvme0n1p3	  32.00MiB

Unallocated:
   /dev/nvme0n1p3	  70.32GiB

A web search for “ btrfs unallocated vs free” comes up with explainations.
Also you might want to check out the btrfs docs Welcome to BTRFS documentation! — BTRFS documentation for design info.

Unallocated refers to blocks that haven’t been assigned to a block group. Extents are a range of blocks. And block groups are a range of extents.

On Btrfs block groups have profiles: single, dup, raid1, raid10 and so on.

And there are two kinds of block groups: data and metadata. (There is also the system block group which is primarily the chunk b-tree but in practice it treated as metadata.)

Free should be the total unused blocks in all types of block groups, plus the unused blocks that haven’t been assigned to any block group.

1 Like

Free tells you how much available space you have for data.

Allocated is more of a btrfs internal statistic. It is worth keeping an eye on though. If your volume becomes fully allocated, you can get in a situation where you have plenty of free space but you can’t write data because the fs can’t provision any new metadata blocks.

An occasional balance will avoid this situation.

1 Like

Yep. I connect the dots. The solution to the current Fedora disk configuration was use

sudo btrfs balance start -d /
sudo btrfs balance start -m /
1 Like

The general recommendation is not to balance without filters and NEVER the metadati, unless you know what you’re doing.

If you’re concerned about edge cases, you can automate it with Btrfsmaintenance, which applies filters.

Or, even better, enable the new “Dynamic Reclaim” feature, which balances ONLY when necessary.