Linux – Raid1 with active and spare partition

linuxmdadmraidsoftware-raidUbuntu

I am having the following problem with a RAID1 software raid partition on my Ubuntu system (10.04 LTS, 2.6.32-24-server in case it matters).

One of my disks (sdb5) reported I/O errors and was therefore marked faulty in the array. The array was then degraded with one active device. Hence, I replaced the harddisk, cloned the partition table and added all new partitions to my raid arrays. After syncing all partitions ended up fine, having 2 active devices – except one of them. The partition which reported the faulty disk before, however, did not include the new partition as an active device but as a spare disk:

md3 : active raid1 sdb5[2] sda5[1]
  4881344 blocks [2/1] [_U]

A detailed look reveals:

root@server:~# mdadm --detail /dev/md3
[...]
Number   Major   Minor   RaidDevice State
   2       8       21        0      spare rebuilding   /dev/sdb5
   1       8        5        1      active sync   /dev/sda5

So here is the question: How do I tell my raid to turn the spare disk into an active one? And why has it been added as a spare device? Recreating or reassembling the array is not an option, because it is my root partition. And I can not find any hints to that subject in the Software Raid HOWTO.

Any help would be appreciated.

Current Solution

I found a solution to my problem, but I am not sure that this is the actual way to do it. Having a closer look at my raid I found that sdb5 was always listed as a spare device:

mdadm --examine /dev/sdb5
[...]
Number   Major   Minor   RaidDevice State
this     2       8       21        2      spare   /dev/sdb5

   0     0       0        0        0      removed
   1     1       8        5        1      active sync   /dev/sda5
   2     2       8       21        2      spare   /dev/sdb5

so readding the device sdb5 to the array md3 always ended up in adding the device as a spare.

Finally I just recreated the array

mdadm --create /dev/md3 --level=1 -n2 -x0 /dev/sda5 /dev/sdb5

which worked.

But the question remains open for me: Is there a better way to manipulate the summaries in the superblock and to tell the array to turn sdb5 from a spare disk to an active disk? I am still curious for an answer.

Best Answer

Daniel: Initially, double-check to see if the spare is being integrated into the array by doing a:

cat /proc/mdstat

which should report if there is a build process going on, and how long to expect that to take.

If no building is occurring, then try the following

mdadm /dev/md3 --remove /dev/sdb5

mdadm /dev/md3 --add /dev/sdb5

And report back how that works for you. See http://linux.die.net/man/8/mdadm for more details.

Related Question