BTRFS Balance Bug in Kernel 5.14.x


There is a trojan horse in kernel 5.14.x which reasons a btrfs filesystem to move read-only when changing the metadata profile from unmarried to dup. The filesystem is going right into a read-only state. Solving this downside calls for an unconventional repair.

About BTRFS Profiles

One of the good options of btrfs is the facility to make use of the other raid profiles. Since btrfs retail outlets the information and metadata one at a time, it’s possible you’ll stripe the information around the disks as raid0 and reflect all of the metadata as raid1. This redundancy in metadata takes little more space. And that is really helpful in btrfs raid0 setups.

It has at all times been steered to replicate the metadata, even on a unmarried disk, since shedding the metadata approach shedding the information as smartly.

Btrfs is in a position to alternate a raid profile on a are living machine, changing the information and metadata to supply (or take away) redundancy. This happens with a stability. A btrfs stability re-writes all of the filesystem’s blocks and adjusts to check the brand new profiles because it does.

The Bug

I tried to modify the metadata profile on my unmarried disk from unmarried to dup for the redundancy.

$ sudo btrfs stability get started -mconvert=dup /mnt

The filesystem in an instant went right into a read-only state. The machine went down. When it rebooted, I may now not get previous the restoration initramfs. No information may well be written to the disk.

When a stability operation is interrupted on btrfs filesystem, it robotically resumes the following time the filesystem is fixed. This can also be generally stopped with:

$ sudo mount -o skip_balance,rw /dev/sdX /mnt

Then, cancel if wanted the usage of the next command:

$ sudo btrfs stability cancel /mnt

However, the trojan horse now not solely brought about the stability to fasten up however the mount choices to prevent it from proceeding had been omitted. Every time the filesystem is fixed, the stability makes an attempt to renew. It failed and the filesystem went directly to read-only. If you come upon this, you will have to boot any distro the usage of an older kernel. In my case, it used to be Arch with 4.18.

Mount the filesystem with the older kenel:

$ sudo mount -o skip_balance,rw /dev/sdX /mnt

Cancel the stability:

$ sudo btrfs stability cancel /mnt

Perform the stability once more:

$ sudo btrfs stability get started -mconvert=dup /mnt

Once the stability is whole, you’ll be able to safely boot right into a more moderen kernel, now with duplicated metadata within the filesystem. Check the profiles utilized by the filesystem. You will see that you’ve got two copies of the filesytem’s metadata and just one reproduction of the information:

$sudo btrfs fi utilization mountpoint>


Btrfs is an ideal filesystem able to many complicated choices. However, when the usage of btrfs, you’ll have operating backups in addition to a bootable kernel from an LTS distro for machine rescue. Even even though a stability can also be run on a fixed root filesystem, it isn’t at all times urged to try this. There are nonetheless many insects within the filesystem. You will have to be ready for a filesystem rescue when the btrfs module hasn’t been totally examined in opposition to bleeding-edge kernels.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More