4

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.

3
  • What fails, precisely: -A, or --run? (They're separate operations and can be performed in either order, unless this is relevant to your bug recovery). What is the exact error message? What does mdadm -D /dev/md2 show? (Expected: spare rebuilding /dev/sdb1, becoming active sync /dev/sdb1 once the rebuilding is finished.) Dec 3, 2010 at 19:14
  • Any resolution for this?
    – belacqua
    Jan 28, 2011 at 2:57
  • @Gilles the -A thinks sdb is a spare, not a data drive, so the --run won't happy.
    – Kees Cook
    Jan 28, 2011 at 22:10

3 Answers 3

2

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.

2
  • 1
    You forgot the cat in the watch command. I can't add this because edits have to be at least 6 characters...
    – leemes
    Nov 21, 2012 at 21:22
  • 1
    After adding a new drive to an existing 2-drive RAID1 array, I was not seeing the new spare rebuilt in /proc/mdstat. Turns out you have to manually tell mdadm to expect 3 drives in the RAID1 array, at which point it will rebuild: superuser.com/a/533707/458816 Jun 14, 2023 at 16:58
2

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:

mdadm --assemble /dev/md2 /dev/sdb1

However if the array is running:

mdadm --manage /dev/md2 -a /dev/sdb1
1
  • For me, mdadm would always refuse acknowledge one of my disks when I tried to assemble. I had to use --manage ... -a on the "failed" disk after assembling it the array. Aug 26, 2018 at 18:28
0

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.

mdadm /dev/md2 --add /dev/sdb1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .