You are not logged in.

#1 2018-05-25 08:39:16

MindfulConsumer
Member
Registered: 2018-03-27
Posts: 19

[SOLVED] How do I run a btrfs balance?

Clonezilla refuses to clone my root partition, (while other partitions on the disk go fine):

https://s7.postimg.cc/ezedlmvm3/IMG_20180523_102122.jpg

Looking for 'set block' + 'out of boundary' I found this thread providing a hint;

run a btrfs balance to fix the out of boundary error

How do I run a btrfs balance? Can I do it while I'm using the computer, or do I need to boot into a live environment first? By reading the man page I understand I can run it while using the computer. What it will do;

btrfs filesystem balance is an operation which simply takes all of the data and metadata on the filesystem, and re-writes it in a different place on the disks, passing it through the allocator algorithm on the way.

But do I have enough space?

the balance operation needs enough work space, ie. space that is completely unused in the filesystem, otherwise this may lead to ENOSPC reports. See the section ENOSPC for more details.

Right, so I checked and there's no free space like that:

devid 1 size 32.00GiB used 32.00GiB path /dev/sda1

So the operation is bound to fail, and my only remaining option according to the man page;

An example of a filter that does not require workspace is usage=0. This will scan through all unused block groups of a given type and will reclaim the space. After that it might be possible to run other filters.

Later on in the man page they show the command:

btrfs balance start -dusage=0 /path

Clear, almost; I want to apply the command only to my root partition, as I fear it will otherwise take all day (I'm assuming I have to run the command again without the '-dusage=0' filter to actually solve the problem). So if I specify the path to be / - well my other partition is mounted on there somewhere, so I'm guessing it will go there recursively or not? If so; how can I prevent that?

Mod edit: Replaced oversized image with URL, please refer to our CoC regarding image sizes -- V1del

Last edited by MindfulConsumer (2018-12-20 14:05:28)

Offline

#2 2018-05-25 11:48:23

ratcheer
Member
Registered: 2011-10-09
Posts: 924

Re: [SOLVED] How do I run a btrfs balance?

Yes, you can balance btrfs while using the computer. Simply run

btrfs balance start -dusage=70 -musage=70 /

You may omit the dusage and musage parameters if you want to do a full balance, but it will take much longer. Try it first with those parameters and, if it doesn't help your problem, run it again without them.

Tim

Last edited by ratcheer (2018-05-25 11:49:04)

Offline

#3 2018-05-31 17:19:11

MindfulConsumer
Member
Registered: 2018-03-27
Posts: 19

Re: [SOLVED] How do I run a btrfs balance?

Whoops, got cought up with other things. Thanks for the advice, one more question I'd like to see answered; I have two partitions right:

sda1 = /
sda3 = /home

So what I can't get my head around is will the balance command on / also effect the sda3 partition?

I don't want that to happen because: Clonezilla only gave error on sda1, not on sda3 - and sda3 is like 10 times the size of sda1.

edit: I tried # btrfs balance start -dusage=70 -musage=70 /

and that resulted in:

# ERROR: error during balancing '/': No space left on device

and I thought yes of course, that's exactly what I figured would happen before. So I tried # btrfs balance start -dusage=0 /

and it immediately put out:

# Done, had to relocate 0 out of 41 chunks

I checked the free space again with #btrfs filesystem show and yes, there is some free space now:

# devid    1 size 32.00GiB used 31.76GiB path /dev/sda1

Now checking if clonezilla works: Nope, it didn't. I removed some files and tried:

# btrfs balance start -d /
ERROR: error during balancing '/': Read-only file system
There may be more info in syslog - try dmesg | tail
# dmesg | tail
[ 4045.731394] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_TIMEOUT
[ 4045.731396] sd 0:0:0:0: [sda] tag#0 CDB: Write(10) 2a 00 02 a5 29 60 00 00 20 00
[ 4045.731397] print_req_error: I/O error, dev sda, sector 44378464
[ 4045.731400] BTRFS error (device sda1): bdev /dev/sda1 errs: wr 28, rd 2, flush 0, corrupt 0, gen 0
[ 4046.017129] BTRFS: error (device sda1) in btrfs_commit_transaction:2262: errno=-5 IO failure (Error while writing out transaction)
[ 4046.017135] BTRFS info (device sda1): forced readonly
[ 4046.017141] BTRFS warning (device sda1): Skipping commit of aborted transaction.
[ 4046.017144] BTRFS: error (device sda1) in cleanup_transaction:1873: errno=-5 IO failure
[ 4046.017148] BTRFS info (device sda1): delayed_refs has NO entry
[ 4046.017514] BTRFS info (device sda1): 10 enospc errors during balance

So things only got worse sad

Last edited by MindfulConsumer (2018-12-20 12:19:14)

Offline

#4 2018-06-01 12:03:50

ratcheer
Member
Registered: 2011-10-09
Posts: 924

Re: [SOLVED] How do I run a btrfs balance?

If / and /home are separate btrfs filesystems, you will have to balance them separately. I.e., if you ran mkfs.btrfs on each partition, they are separate filesystems. This is most likely your configuration, from the description you're giving.

If you run balance with -dusage=0, you are telling it to defrag nothing. That is why it completes, immediately. Try 20 to see if you can free up some space, then try higher percentages.

By any chance, did you convert the filesystem from ext4 to btrfs? If so, you can delete the backup of the old ext4 filesystem, then balance the btrfs to straighten things out. If your btrfs is actually full, I am surprised you can boot your system without throwing it into read-only mode.

Tim

Offline

#5 2018-06-03 08:38:05

MindfulConsumer
Member
Registered: 2018-03-27
Posts: 19

Re: [SOLVED] How do I run a btrfs balance?

ratcheer wrote:

If / and /home are separate btrfs filesystems, you will have to balance them separately. I.e., if you ran mkfs.btrfs on each partition, they are separate filesystems. This is most likely your configuration, from the description you're giving.

Clear, good to know!

By any chance, did you convert the filesystem from ext4 to btrfs?

No, I started out with btrfs from the beginning. The system is rock stable, with two things wrong:

1) when I 'Check' the filesystem with Gparted it aborts with 'ERROR: errors found in fs roots'
2) Clonezilla refuses to clone the sda1 partition and aborts with 'set block [..] out of boundary [..]'

The reason why I'm so careful is that besides me there's only one other person I can find on the whole internet who also had that 'set block [..] out of boundary [..]' error.

Now after trying the full balance command and the system hanging in read-only mode (probably because of lack of space), I booted into a live environment, mounted sda1 and ran the full balancing command again - with success! It was actually very fast - and better yet doing the check with Gparted now completed without errors so it definitely fixed something. I think it was fast because I used the 'btrfs balance start -d /' - I read it doesn't matter if you run it with -d or not but I guess it does.

Sadly nothing changed for Clonezilla - still aborting the process with 'set block [..] out of boundary [..]' - Of course I was suspicious of the short time it took to do the balance in the live environment. Been reading some more, this was interesting, explains you can just add space from a USB stick or whatever to the partition to temporarily expand it so you can run the balance. Though his commands seemed complicated I thougth of something else; I decreased my swap partition from 4 to 1 GB and this is pretty cool; I could expand my root partition with those 3GB while running the system within seconds with Gparted. Now ran the full balance again and this time it took about an hour to complete. Result: now I could finaly clone my disk with Clonezilla smile

SOLVED!

Last edited by MindfulConsumer (2018-12-20 12:18:30)

Offline

Board footer

Powered by FluxBB