In an effort to clean up from a software bug in md, I marked half of a RAID (/dev/sda1 and /dev/sdb1 in RAID1) as faulty using:
mdadm /dev/md2 --fail /dev/sdb1
mdadm /dev/md2 --remove /dev/sdb1
But now I want to use the "failed" half instead. i.e. instead of using /dev/sda1
, I want to use /dev/sdb1
, but mdadm refuses to bring it online:
mdadm --stop /dev/md2
mdadm -A /dev/md2 /dev/sdb1 --run --force
This fails, as it considers /dev/sdb1
a "spare" and not an actual member of the array any more.
You're using
-A
which is--assemble
, but you should be using-a
which is--add
.If I recall correctly, devices (re)added to an existing array are always added as spares, then shortly afterwards the kernel will pick up that the array is both degraded and has a spare, and then it will start re-mirroring. You can see this with
watch cat /proc/mdstat
.The entire command that should be run is one of the following assuming the array is not assembled or running (which the OP shows as not running):
If the array is not running:
However if the array is running:
I think that the simpliest way to unmark the partition would be to add it again to the array. By the way, if you need to do a test, don't remove the drive from the array. Flag it as faulty and if you reboot, it will fall back on the other partition.