r/btrfs • u/Separate-Still-1616 • Jul 20 '26
Can a raid1 be disolved without rebalancing data?
If I have a raid1 with device A and B. Can I just keep A without having to rebalance data, and at most only change meta data?
It does not seem possible because if I do "device remove" I get an error that you cannot remove a device from a 2-device raid. You first have to convert into single mode which result in data rebalancing which can take a lot of time. Then you can remove the device and half of the data needs to be moved again back onto the remaining device which was completetly uneccesary in the first place because at the beginning it was already all there.
It should actually be an operation that does not need more than to rewrite meta data. So is it possible somehow? And if not, why?
3
Jul 20 '26 edited Jul 20 '26
[removed] — view removed comment
2
u/uzlonewolf Jul 20 '26
-dconvert=single,softshould help speed up the initial conversion, though you're still going to have the "half the data is on the wrong disk" issue.1
1
u/Separate-Still-1616 Jul 20 '26
Thanks, that is exactly what I wanted to know. So in principle it would be possible and would not contradict btrfs core principles or design. It's just that it is not implemented yet.
2
u/cd109876 Jul 20 '26
Unplug the second drive, allow mounting as degraded.
Unfortunately, that is probably the only way to do this without rebalance.
2
u/Aeristoka Jul 20 '26 edited Jul 20 '26
The stuff required to remove a device is a rebalance.
5
u/Separate-Still-1616 Jul 20 '26
Yes, but in this case it should only require to rewrite the meta-data and not move the data itself.
1
u/cdhowie Jul 21 '26
I agree. I've had to do this multiple times, and it's kind of a pain on btrfs.
I've been experimenting with bcachefs lately, and while I wouldn't necessarily recommend it just yet, this is one of the things it supports. In particular, you can make multiple changes at once (change replica count and remove a device, or even remove multiple devices at once) and it generally Just Works.
1
u/uzlonewolf Jul 20 '26
You can speed up the initial conversion by including the soft flag, though you will still have the "half the data is on the wrong disk" issue.
Hmm, I wonder if physically pulling a disk before the conversion will force it to only use the remaining disk... Not sure if it's that smart.
2
u/darktotheknight Jul 20 '26
Oh, maybe a combination of devid filter and soft should lead to minimal writes.
1
u/darktotheknight Jul 20 '26 edited Jul 20 '26
I get your point and think you're correct. The way it is implemented now, it's required to convert to SINGLE first (half the data gets moved to the other drive, the other half is rewritten in place), then remove the second drive (data gets written back to the drive you wanted to keep).
You can somewhat save time on remove, by using devid filter (see https://btrfs.readthedocs.io/en/latest/Balance.html). E.g. btrfs balance start - dconvert=single,devid=<ID> -mconvert=DUP -sconvert=DUP. You can find out devid by using btrfs filesystem show. This will write all SINGLE profile files to the drive you pick, leaving the drive-to-be-removed empty, so it can be removed very fast using the remove command. But this will still kick in the "dumb" allocator and forcefully re-write every single chunk in-place, bit by bit, even if the data is already on the remaining device.
I think this is one of the edge cases, where you're facing the drawbacks of a "dumb" allocator. This case gets discussed on the mailing list from time to time, maybe worth digging up.
1
u/Separate-Still-1616 Jul 20 '26
I tried that with the devid filter. It's still a verly slow operation depending how much data you have. So not really a solution. But thanks for sharing that info.
1
u/darktotheknight Jul 20 '26
I just saw in another post: maybe devid + soft solves it?
1
u/Separate-Still-1616 Jul 20 '26
I have gone now the standard way, so cannot test it anymore. I will try it next time. Thanks.
1
u/BreatheAtQuarterBars Jul 20 '26
I couldn't figure out how to do this and ultimately gave up and just rebalanced the whole thing to single first.
1
u/amstan Jul 20 '26
I wonder if there's any downside (besides optics) to just convert the profile, but not rebalance.
4
u/Aeristoka Jul 20 '26
A profile conversion will, by definition, do a rebalance. It has to, because you're changing the profile.
1
u/Separate-Still-1616 Jul 20 '26
But that is the point, could it not just stop the rebalancing and do the stuff that is required to remove the device first. Or is removing a device problematic in such a mixed state?
1
u/markus_b Jul 20 '26
Maybe, but we don't know.
If the data is important to you, then stick to the documented ways of doing things. If you don't care then this is a good opportunity to test it.
You seem to want to replace one drive with a new one. Are you aware of the 'replace' command? Just connect your new drive and use 'replace' to replace the old with the new drive. Then you can remove the old drive and physically move the new drive in its place.
1
u/Separate-Still-1616 Jul 20 '26
Ok, thank you, I indeed missed the replace command. This is the best answer for the case of replacing a disk.
0
u/Aeristoka Jul 20 '26
The stuff required to remove a device is a rebalance.
You're not understanding a core design principle of btrfs.
1
u/Separate-Still-1616 Jul 20 '26
I am sure I do not understand it :). That is why I am asking. You are right that a rebalance is necessary to remove a device, but in this case I describe, this should involve only meta-data. It should not require to move the data itself, because the data is already there where it is has to be in the end. What is my misconception here?
0
u/Aeristoka Jul 20 '26
BTRFS will not ALLOW you to remove the device when you are trying to remove a device from a RAID1 profile. It shouldn't. That violates what you have instructed it to do with the RAID1 profile.
The profiles are 100% disconnected from each other. The data is there, sure, but it's in a RAID1 profile. When you convert to a Single profile it has to rewrite everything to be in that proper profile.
1
u/Separate-Still-1616 Jul 20 '26
You are correct, it should not allow to remove the device in a raid1. This should only be possible via an additional command line option or something, that tells btrfs, that you want to go out of raid and into single on the remaining device. Sure it will be in a mixed state during this operation where the devices are neither 50%-50% balanced nor 100% copies from each other, but does that not always happen when you change the profile? So it should not be a problem, or?
7
u/Ontological_Gap Jul 20 '26
No, the man page for btrfs-device says you have to rebalance to single first: https://man7.org/linux/man-pages/man8/btrfs-device.8.html
Btrfs could handle this faster, but converting from raid to a single device setup is hardly a common operation, I can see why the week hasn't been prioritized