Raid1 with active and spare partition
        Posted  
        
            by 
                Daniel Baron
            
        on Super User
        
        See other posts from Super User
        
            or by Daniel Baron
        
        
        
        Published on 2011-02-14T14:47:45Z
        Indexed on 
            2012/06/27
            21:20 UTC
        
        
        Read the original article
        Hit count: 352
        
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.
© Super User or respective owner