Ask / Submit

It seems btrfs-balancer cannot balance properly [duplicate]

asked 2017-03-26 21:19:09 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2017-04-01 15:13:11 +0300

pawel gravatar image


I'm using SailFish OS (didn't upgrade to 2.0.5 because of Wifi issues).

I have 75% of the space occupied :

$ df -h /home/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mmcblk0p28        14G  9.8G  3.3G  75% /home

But sudo btrfs-balancer allocation says Allocated: 100 % so I run a :

$ time sudo btrfs-balancer balance
Balancing... 0 %
Balancing... 10 %
Balancing... 10 %
Balancing... 20 %
Balancing... 35 %
Balancing... 50 %
Balancing... 75 %
Balancing... 96 %
Balancing... 97 %
Balancing... 98 %
Balancing... 100 %

real    2m29.322s
user    0m0.030s
sys 0m0.030s

Then I check with :

$ sudo btrfs-balancer allocation
Total:     14763950080 bytes
Used:      14763950080 bytes
Allocated: 100 %

But a "btrfs df" says :

$ btrfs filesystem df /      
Data, single: total=12.51GiB, used=9.24GiB
System, DUP: total=40.00MiB, used=4.00KiB
System, single: total=4.00MiB, used=0.00
Metadata, DUP: total=586.00MiB, used=283.70MiB
Metadata, single: total=8.00MiB, used=0.00

I have the btrfs-balance tool from :

$ zypper what-provides btrfs-balancer
Loading repository data...
Reading installed packages...
S | Name           | Type    | Version     | Arch    | Repository
i | btrfs-balancer | package | 1.2.4-1.2.4 | armv7hl | jolla

After stopping the Android support and 10 balancings, the result is still the same :(

Knowing that my /home FS is 687 MiB and "my android_storage" FS is 1.76 GiB.

Therefore my personal data takes upto 2480 MiB out of 14078 MiB (size of /home FS) that is 17.61%

All the rest does not belong to the nemo user.

Can you help me ?

edit retag flag offensive reopen delete

The question has been closed for the following reason "duplicate question" by olf
close date 2017-03-31 15:05:14.061278



I think that for btrfs-balancer to be able to get one or two superblocks of unallocated space on Jolla, df -h should show max 7.5 GB of data. This of course depends on the amount and size of files too.

Manatus ( 2017-03-27 08:22:44 +0300 )edit

I have to run btrfs-balancer balance at least three times before the allocation returns to normal

till ( 2017-03-27 15:33:41 +0300 )edit

@till I did it more than 5 times but still no improvement :( :

$ sudo btrfs-balancer allocation                                                                                                               
Total:     14763950080 bytes
Used:      14763950080 bytes
Allocated: 100 %
SebM ( 2017-03-27 16:12:40 +0300 )edit

empty some space on your device,then run btfs balancer. when my device was near 100%, i had to empty 6 gb to get significant improvements

pawel ( 2017-03-27 21:55:47 +0300 )edit

@pawel 75% is the df usage of my filesystem AFTER I had freed the space I could.

SebM ( 2017-03-28 17:08:42 +0300 )edit

2 Answers

Sort by » oldest newest most voted

answered 2017-03-27 23:34:12 +0300

olf gravatar image

updated 2017-03-28 01:30:05 +0300

a. A divergence between df's and btrfs-balancer allocation's output is "normal", though irritating on first sight. E.g. my Jolla 1 (SFOS, but that has always been like that) is currently at 69% used (df) vs. 90% (btrfs-balancer allocation).

b. Note that technically BTRFS Allocation is different from the classic "space used", so differing outputs are expected.

c. With well over 80% allocation (as reported by btrfs-balancer allocation; usually 83 to 87%) one starts to experience "hiccups" (short, temporary slow-downs / intermittently hanging GUI / "unresponsiveness") and SFOS updates may fail or need two runs to finish. At around 90% allocation the "hiccups" become prominent and SFOS updates will likely fail. (Oh, I have to clean up, so thanks for making me check, see a.)

d. Due to the way BTRFS works (COW etc.), small changes in the file system may lead to excessively increased BTRFS Allocation, especially when already at more than 80% (this effect becomes exponentially worse with increasing allocation). So better try to keep 20% unallocated, as spare area for BTRFS to maneuver.

e. Trust the output of btrfs-balancer allocation, when the btrfs-balancer balanced "successfully" 2 or 3 times in a row, but the allocation percentage did not decrease from the second last run to the last one.

f. For convenient checking and balancing via GUI, you may use "BTRFS balance checker 2" from Warehouse.

P.S.: Reducing the amount of file system activity and number of open files makes the BTRFS balancer's job (i.e. balancing) easier and more effective, so switch the "Android support after boot" off, reboot, let the device settle (i.e. wait for a minute) and just run the BTRFS balancer (i.e. without starting any other program or doing anything else).

edit flag offensive delete publish link more



He didn't even read the first comment (2 lines) where there is the answer to his problem so I don't think he will read your long answer ;)

Sthocs ( 2017-03-28 10:57:20 +0300 )edit

@Sthocs I DID read every answers, but the thing is :

75% is the df usage of my filesystem AFTER I had freed the space I could.

I don't see why Jolla choose BTRFS if it is such a pain to maintain.

I mean, an average user does not know and care about btrfs-balance. Why isn't the btrfs balancing done automatically ?

SebM ( 2017-03-28 17:01:52 +0300 )edit

@olf Thanks olf for your great analysis. I'll switch off the Android support before starting the balancing when I get back home (tonight).

SebM ( 2017-03-28 17:05:57 +0300 )edit

It is done regularly, but it needs a "do not reboot" situation, so this happens only at SFOS updates (and while over 75 or 80% allocation).

But I agree with @Sthocs and concur with @Manatus, that the only specific advice here is: Delete or move (e.g. to SDcard) more stuff from internal mass storage! With significantly more than 7.5 GB used (per df) you probably will not get lucky.

olf ( 2017-03-29 01:49:47 +0300 )edit

@old I will try and free some more space tomorrow night.

Knowing almost all of my data is in the SD card.

I wish Jolla had chosen something else than btrfs.

Thanks every one for your help.

SebM ( 2017-03-29 02:20:17 +0300 )edit

answered 2017-03-31 15:03:45 +0300

olf gravatar image

updated 2017-03-31 15:40:12 +0300

Hey Seb, this is TJC, not! Please take a thorough look around, before asking us volunteers on TJC issues, which have been tackled numerous times already, e.g.:

For further reading, please see the "See also ..." list on the right hand side of these pages and the general BTRFS documentation, e.g.

P.S.: For finding "space hogs" (cache directories etc., you may not be aware of) Space Inspector (a tree view utility) from the Jolla Store is quite useful.

P.P.S.: Caches of Android apps, especially app stores (F-Droid, Aptoide etc.), can become quite large: Clean them "in app" (in their settings) first (but not their configuration data).

Then/additionally you may use 'Settings-->Apps-->[android-app-name]-->Clean cache' (but not 'Clear data') for any Android app you suspect caching a lot. This is safer and easier than deleting these caches manually.

For SFOS apps, cleaning their caches in /home/nemo/.cache/ has to be done manually, but I found only ~/.cache/harbour-meecast/* to be problematic (due to a already reported / known bug; you can just empty Meecast's cache directory completely, as it should be the case for the other directories in ~/.cache/, too).

edit flag offensive delete publish link more

Question tools

1 follower


Asked: 2017-03-26 21:19:09 +0300

Seen: 1,024 times

Last updated: Mar 31 '17