Btrfs out of space, but OS reports lots of disk space free [duplicate]

I'm using Btrfs, for better or worse. It is a plain btrfs partition with no compression or RAID, nor do I have any snapshots; it is a a simple btrfs partition that the OS is reporting with quite a bit of space free, but I am getting out of space errors when running various operations such as updates.

The operating system tools such as df report lots of space free:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G   26M  1.6G   2% /run
/dev/sda5       354G  313G   41G  89% /
tmpfs           7.9G  172M  7.7G   3% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda5       354G  313G   41G  89% /home
tmpfs           1.6G  4.0K  1.6G   1% /run/user/139
tmpfs           1.6G   20K  1.6G   1% /run/user/1000

I later found the btrfs tool to show information about the btrfs volumes:

$ btrfs fi show
 Label: none  uuid: 76eb29fb-6909-4cc9-9848-f0b5723802b9
    Total devices 1 FS bytes used 285.88GiB
    devid    1 size 353.90GiB used 349.90GiB path /dev/sda5

 Label: none  uuid: 229c7745-144f-4dd0-98c5-476248b308ad
    Total devices 1 FS bytes used 384.00KiB
    devid    1 size 348.77GiB used 1.02GiB path /dev/sda3

/dev/sda5 is 286GB used with as size of 354GB. Then says 350GB used.

/dev/sda5 is mounted as /

How do I get access to the ~60GB that it says are free, but are not?


Solution 1:

Btrfs has not freed up blocks for reuse. For Btrfs, this is a manual process.

btrfs balance start / is the command to do this process.

  Done, had to relocate 352 out of 352 chunks

It will take a long time to complete, but you can check on the progress of the command in another console window with:

$ btrfs balance status /
Balance on '/' is running
239 out of about 352 chunks balanced (240 considered),  32% left

Once the rebalance operation was completed:

$ btrfs fi show
Label: none  uuid: 76eb29fb-6909-4cc9-9848-f0b5723802b9
    Total devices 1 FS bytes used 287.93GiB
    devid    1 size 353.90GiB used 298.90GiB path /dev/sda5

Label: none  uuid: 229c7745-144f-4dd0-98c5-476248b308ad
    Total devices 1 FS bytes used 384.00KiB
    devid    1 size 348.77GiB used 1.02GiB path /dev/sda3