5

Today my desktop gave me a notification that my /-filesystem was 'full'. So at first i did some cleanup of files, packages and old snapshots.

However, when i removed the previous i noticed with the tool baobab that i only have 50GB of space (see screenshot). My df -alh command give me the result that my size is 140G and the command btrfs filesystem df / gave me the result 125G. If i check the partition size with cfdisk i get the result that if have 139,7G (so say 140G) available, corresponding the df -alh command. However i don't understand why the btrfs and baobab give me different results. Screenshot difference size output

--Edit--

$sudo  btrfs fi usage /
Overall:
    Device size:         139.70GiB
    Device allocated:        136.70GiB
    Device unallocated:        3.00GiB
    Device missing:          0.00B
    Used:            133.78GiB
    Free (estimated):          3.63GiB  (min: 2.13GiB)
    Data ratio:               1.00
    Metadata ratio:           2.00
    Global reserve:      308.56MiB  (used: 0.00B)

Data,single: Size:125.68GiB, Used:125.05GiB (99.50%)
   /dev/sda1     125.68GiB

Metadata,DUP: Size:5.50GiB, Used:4.37GiB (79.38%)
   /dev/sda1      11.00GiB

System,DUP: Size:8.00MiB, Used:16.00KiB (0.20%)
   /dev/sda1      16.00MiB

Unallocated:
   /dev/sda1       3.00GiB
$sudo btrfs fi du -s /
     Total   Exclusive  Set shared  Filename
 138.88GiB    96.00KiB    46.30GiB  /
3
  • What do you get from btrfs fi usage / and btrfs fi du -s /? Sep 4, 2020 at 10:18
  • Would still like to see results of the second command, as it can explain the numbers shown by Baobab. Sep 4, 2020 at 11:13
  • @user1686: I added the results of btrfs fi du -s/
    – Dave -
    Sep 4, 2020 at 15:43

1 Answer 1

7

With BTRFS, it is possible to run out of space when writing an amount of data that is much less than the reported free space.

This is because BTRFS starts every write in a freshly allocated chunk. But as the chunksize is static, and files come in all sizes, much of the time a chunk is incompletely filled. That creates “allocated but not used” space that is the problem.

You may see the problem better using the command btrfs fi usage. Divide the used-size by total-size to get the ratio of inefficient storage.

BTRFS has a tool to "rebalance" your filesystem, called balance. Originally designed for balancing data stored across multiple drives, it is also useful in single drive configurations though, to rebalance how data is stored within the allocation.

By default, balance will rewrite all the data on the disk. This is probably unnecessary. Chunks will be unevenly filled, but you can use the above-calculated ratio to filter, using the -d parameter to only rebalance chunks that are less than that ratio. That will leave any partially filled chunks which are more-filled than the average.

If the ratio was 0.66, use the following command:

sudo btrfs balance start -dusage=66 /

You can run the above command in the background by appending & and check on its status using:

sudo btrfs balance status -v /

Or continuously using:

while :; do sudo btrfs balance status -v / ; sleep 60; done

To see the difference, check out the final result using:

btrfs filesystem df /

For more details see the article BTRFS and Free Space - Emergency Response.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .