Dealing with the fucking BTRFS

BTRFS is supposed to mean "Better File System." As far as I am concerned it's a worser, far worser file system. I've never before had a file system crash, take down my OS and require me to go through some arcane fucking magic to rebalance my metadata FFS.

So it's WRSRFS not BTRFS

And I've had to do it three times, so far. I am getting away from it as soon as I can do so safely.

In the meantime, here's the article that I spent hours finding the first time, and tens of minutes the second time, only because I remembered that I had sent a hangouts chat message to someone with the URL of the article.

Well, next time it might not be there. So if google doesn't Dennis Cooper me, here's the backup version.

The original is (or was) here.

The important parts are repeated below with comments and shit.

To get a list of all the places where WRSRFS is to be found:

btrfs fi show


To find out the state of your WRSFRS data: 


To balance your WRSRFS, something like this:
                             
mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=50 /home                             
Dumping filters: flags 0x1, state 0x0, force is off                                                          
  DATA (flags 0x2): balancing, usage=50                                                                             
ERROR: error during balancing '/home': No space left on device 

Which basically means that you are semi-fucked. So you have to balance out smaller chunks before you get there. Like this: So change the -dusage parameter to something smaller and work your way up:
                                                                
mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=20 /home                             
                                                                          
mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=20 /home                             
Dumping filters: flags 0x1, state 0x0, force is off                                                                 
  DATA (flags 0x2): balancing, usage=20                                                                             
Done, had to relocate 1 out of 22 chunks                                                                            
mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=30 /home                             
Dumping filters: flags 0x1, state 0x0, force is off                                                                 
  DATA (flags 0x2): balancing, usage=30

Done, had to relocate 1 out of 22 chunks

mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=40 /home  
Dumping filters: flags 0x1, state 0x0, force is off

  DATA (flags 0x2): balancing, usage=40

Done, had to relocate 1 out of 22 chunks

mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=50 /home  
Dumping filters: flags 0x1, state 0x0, force is off

  DATA (flags 0x2): balancing, usage=50

Done, had to relocate 1 out of 22 chunks

And now it fucking works. So continue:


mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=60 /home  
Dumping filters: flags 0x1, state 0x0, force is off

  DATA (flags 0x2): balancing, usage=60

Done, had to relocate 3 out of 22 chunks

This takes some time to run. If you repeat you get:
mwolf@mwolf-ThinkPad-W520:~/tools/fbstory$ sudo btrfs balance start -v -dusage=60 /home   Dumping filters: flags 0x1, state 0x0, force is off  DATA (flags 0x2): balancing, usage=60 Done, had to relocate 1 out of 21 chunks


And that takes no time.  If I repeat that command now, I get the same number. So it appears that once you get to 1 chunk it repeats that way.

Now the fun stuff. What if you can't balance anything. Not even at -dusage=1. In that case you've got to do this:
1. Add more space to the drive by adding another device
2. Balance
3. Remove the device

So something like this:

$dd if=/dev/zero of=/var/tmp/btrfs bs=1G count=5
5+0 records in
5+0 records out
5368709120 bytes (5.4 GB) copied, 7.68099 s, 699 MB/s

That creates some space that you can turn into a loop device (whatever that is)
$losetup -v -f /var/tmp/btrfs
Loop device is /dev/loop0

That creates the actual loop device
$btrfs device add /dev/loop0 /home
Performing full device TRIM (5.00GiB) ...

That adds the loop device as a new volume.

Noe you can balance, as above. And when you are done:

btrfs device delete /dev/loop0 /home





Comments

Popular Posts