We have moved to a new Sailfish OS Forum. Please start new discussions there.
16

[how-to] Btrfs allocation 100% - What can i do? - Get more space with outsorcing to SD-Card [HIGHRISK-READ-CAREFULLY-BEFORE-TRY]

asked 2016-05-04 11:23:00 +0300

evo3de gravatar image

updated 2016-05-18 12:15:26 +0300

!!! WARNING: READ CAREFULLY AND COMPLETLY BEFORE DOING SOMETHING - HIGHRISK OF BTRFS CORRUPTION AND NEED OF DEVICE BRIK IF DONE WRONG !!!

Btrfs is a cool file system, but with all cool things there are also uncool trace-appearance, too. One of this is that the Btrfs seems to run full of space. This means it have a poor performance like a fraqmented FAT device. So we have to maintain our filesystem fequently.

Note: It´s better that your device is connected to the carger and not in use while doing this. Also do not boot your device while it is not finished. The device may be unresponsible for a long time, because it need a lot of performance, be patient and wait.

Edit: To reduce the risk of breaking your device, go to Airplain-Mode, close all open apps and stop dalvik

!!! WARNING !!! NEVER, NEVER BOOT WHILE BALANCING - IT WILL BREAK YOUR DEVICE !!!

Doing by terminal

Enter Root mode

devel-su

Check the allocation (how many space is free / how unbalanced is your filesystem)

btrfs-balancer allocation

Note: everything over 90% is critical for the performance and the stability of the system

Balance the Btrfs Filesystem

btrfs-balancer balance

Now you can realocate the data chunks

btrfs balance start -dusage=55 /

If no space is left, try a lower number. But retry later with higher numbers up to 90% Edit: more than 90% can sometimes make your device to stay at a unresponsible condition for a long time > 12 h

Sometimes the Metadata also unbalanced, you can also realocate the metadata using this

    btrfs balance start -musage=55 /

Note: The option -d stand for data and -m for metadata

Now we create a new loop device on the sd-card to outsorce space for balancing

First we have to check what name our sdcard have

ls /media/sdcard

Now we create a loop device on the sdcard and set it up to btrfs

 dd if=/dev/zero of=/media/sdcard/***ID-OF-YOUR-SDCARD***/btrfs bs=100M count=5
losetup -v -f /media/sdcard/***ID-OF-YOUR-SDCARD***/btrfs
btrfs device add /dev/loop0 /

Now we can retry to balance the filesystem.

After balancing is finished, delete the Loop0 device. I´m not sure whats happens if you reboot / disconnect your sdcard while Loop0 is existing.

btrfs device delete /dev/loop0 /

Edit: It seems to be that in some cases the whole btrfs File system will be corrupted if /dev/loop0 will not be deleted before reboot.

If /dev/loop0 can not be deleted, never reboot! Try to balance again and again, delete local data until you can delete it. Write here for help but never reboot it. Hope this will help other solving the btrfs problem

Thanks to: https://together.jolla.com/question/30822/root-and-home-disks-full-and-causing-various-problems/ @juho, https://btrfs.wiki.kernel.org/index.php/Balance_Filters

Edit: Have anyone an other solution for the situation that the Loop0 can not be deleted?

edit retag flag offensive close delete

Comments

1

Why creating this duplicate for the question you refer too? Everything you mention is already there, except the -musage option. You can simply suggest @Manatus to add it, instead of splitting the information.

Sthocs ( 2016-05-04 11:58:05 +0300 )edit
3

2 reduce, silplify and explain what we do at the terminal. Often i see howtos without description what the comand do. Yes, i´m it professional, but what will a unproffesional think.

I do this additional, that other can see the possibility tho outsorce the /dev/zero. Offcorse i found this coincidentally

There was no chance to find it at the search

evo3de ( 2016-05-04 12:35:49 +0300 )edit
1

I think this is very helpful since I'm a complete novice when talking about commandline. It is nice to have descriptions and everything in chronological order.

I have used commandline just once since the discussions about the code are usually just gibberish for a guy like me who uses jolla just because I want to support european operating system, not because I want code my own distro or use commandline to make a call.

The first time I used command line was last week because I ran in problems with warehouse and had to change the version to saimaa from "latest" it is sometimes a pain in the ass to find info from TJC if one does hardly know what to look for.

anza ( 2016-05-04 14:20:46 +0300 )edit
4

That article of mine has spawled a bit out of my hands, eg. I don't know where to go from there. I thought of deleting it and doing simple instructions in the style of this how-to, but then it summarizes the problem pretty good currently, so it is more useful in that old form. (Which is also why I haven't wikied it.)

I think that how-to-article is a good way to go with this useful (bit risky) trick. Thanks!

Manatus ( 2016-05-04 14:32:26 +0300 )edit
1

Last command "btrfs device delete /dev/loop0 /" didn't worked for me and now my device have btrfs file system corrupted and, as far I tried, can not be repaired. I'll try a full recovery tomorrow. :(

tvicol ( 2016-05-04 19:39:46 +0300 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2016-05-12 13:05:39 +0300

mgfm99 gravatar image

The problem that I encountered in the past is that without the correct flag the loop device is added in Raid 1 so that data and metadata are spread across the file system and loop device. It won't allow you to delete the loop device if that compromises the integrity of the metadata too much. Basically you have to reduce the amount of data/metadata to a point that it can all be read back into the filesystem when you delete the loop device. You may have to force a rebalance after deleting the loop device. Unless things have changed - once you have corrupted the BTRFS file system, recovery mode won't help because it doesn't provide a straightforward way of reformatting mmcblk0p28 to allow you to write a new image onto it.

edit flag offensive delete publish link more

Comments

Have you tried to rebalance as Single before deleting the loop?

chemist ( 2016-05-12 14:11:32 +0300 )edit

nvm deleting should reorder already, then it is indeed just a matter of used space and then why not just delete enough data in the first place? (and skip the loop hassle)

chemist ( 2016-05-12 14:14:44 +0300 )edit
Login/Signup to Answer

Question tools

Follow
12 followers

Stats

Asked: 2016-05-04 11:23:00 +0300

Seen: 2,068 times

Last updated: May 18 '16