Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
What does " cat /proc/mdstat" show? Isn't it just rebuilding and the "spare" will just dissapear when the rebuild is finished? What does "mdadm --version" show? There was an old bug ... see . – rems Feb 14 '11 at 14:54
No, that is the problem. The first snippet in the question shows the output of /proc/mdstat for the array. The device has been synced already, but as you can see after the successful syncing process the device remains as a spare and is not turned into an active one. – Daniel Baron Feb 14 '11 at 14:57
mdadm - v2.6.7.1 – Daniel Baron Feb 14 '11 at 14:59

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 for more details.

share|improve this answer
Thanks for your help, Rolnik. As you can see from my first snippet /proc/mdstat shows both devices in the array. The device has already been synced before (not shown here) without problems. But after finishing the resync process the devices was not turned into an active device. Removing and adding again did not change this behaviour. – Daniel Baron Feb 14 '11 at 15:29

Quite late, but doing this would just enable the spare drive:

mdadm --grow /dev/md3 -n 2

As the manpage says:

For create, build, or grow: -n, --raid-devices= Specify the number of active devices in the array. This, plus the number of spare devices (see below) must equal the number of component- devices (including "missing" devices) that are listed on the command line for --create. Setting a value of 1 is probably a mistake and so requires that --force be specified first. A value of 1 will then be allowed for linear, multipath, RAID0 and RAID1. It is never allowed for RAID4, RAID5 or RAID6. This number can only be changed using --grow for RAID1, RAID4, RAID5 and RAID6 arrays, and only on kernels which provide the necessary sup‐ port.

share|improve this answer

From what I recall, when I had that problem (for a different reason) I had to use --grow to re-add the spare drive "properly" (also clearing the error condition.)

Something like this (verify with your documentation!):

mdadm --grow --level=faulty --layout=flush /dev/sdb5

Then you can add the device and it should be recognized.

The problem is that the md driver saves the status of each partitions in the drives boot data. So even after a reboot it knows the status and avoids partitions marked as faulty.

share|improve this answer

You must log in to answer this question.

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