Raid1 with active and spare partition

6,183

Solution 1

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.

Solution 2

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:
6,183

Related videos on Youtube

Daniel Baron
Author by

Daniel Baron

Updated on September 17, 2022

Comments

  • Daniel Baron
    Daniel Baron over 1 year

    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.

    • rems
      rems over 13 years
      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 mail-archive.com/[email protected]/msg09818.html .
    • Daniel Baron
      Daniel Baron over 13 years
      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
      Daniel Baron over 13 years
      mdadm - v2.6.7.1
  • Daniel Baron
    Daniel Baron over 13 years
    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.