On 2019-04-28 12:18, Alberto Bursi wrote:
I am looking for a way to mimic mdadm's behaviour and have btrfs mount
a degraded array on boot as long as it's not broken (specific use case:
RAID1 with a single disk missing/dead)
So far the only thing I could think of (and I've seen suggested
elsewhere) is to add the "degraded" mount option
in kernel command line and in /etc/fstab.
But on the wiki I read that this is a bad idea because of what they call
"Incomplete chunk conversion" issue [1]
that says I can only mount it degraded (when it is actually missing a
disk) rw ONE TIME and then the filesystem would go ro.
Is that still a thing? Are there other ways of doing what I want?
Yes, but it only matters if a couple of specific conditions are met:
* You have exactly two disks in the healthy filesystem.
* Exactly one of those two disks is missing.
* The filesystem has to allocate a new chunk when you are writing data
to it.
That last condition is almost impossible to be certain about, so you
really only need to pay attention to the first two points.
Now, that said, having 'degraded' as part of your standard options is
less than ideal for multiple reasons:
* It makes it very easy to not actually notice that one of your storage
devices is having issues. Unless you're paying attention to the kernel
logs, or you have _something_ that's validating observed hardware state
against known correct state, your only indication that something is
wrong will be reduced performance. MD, LVM, and even ZFS have easy to
use notification mechanisms that can trivially be configured to let you
know if a disk is missing or misbehaving, but BTRFS just doesn't have
any equivalent right now.
* It indirectly encourages running volumes in degraded mode under
otherwise normal system operation, which is risky because it's largely
untested (and is also just a bad idea, independent of what your storage
stack looks like).
* If you're doing this on a system using systemd, it actually doesn't do
what you are trying to do. Systemd will refuse to mount the volume if
all the constituent devices aren't present, so you're going to fail to
mount with or without the 'degraded' mount option if you have a disk
missing.
Unfortunately though, there's not really any other option currently to
do this with BTRFS unless you script something yourself (not
particularly hard with traditional init systems, but somewhat difficult
with systemd because of the aforementioned issue).