Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to create a software raid5 array using mdadm:

$ linux # mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 --spare-devices=0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 64K
mdadm: array /dev/md0 started.

However when inspecting /proc/mdstat

Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdd1[4] sdc1[2] sdb1[1] sda1[0]
      2930279808 blocks level 5, 64k chunk, algorithm 2 [4/3] [UUU_]
      [>....................]  recovery =  0.3% (2970496/976759936) finish=186.1min speed=87172K/sec

unused devices: <none>

It seems one drive isn't active, so I check the details of the array:

/dev/md0:
        Version : 00.90.03
  Creation Time : Tue Jul 21 16:29:53 2009
     Raid Level : raid5
     Array Size : 2930279808 (2794.53 GiB 3000.61 GB)
  Used Dev Size : 976759936 (931.51 GiB 1000.20 GB)
   Raid Devices : 4
  Total Devices : 4
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Tue Jul 21 16:29:53 2009
          State : clean, degraded, recovering
 Active Devices : 3
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 64K

 Rebuild Status : 0% complete

           UUID : ce8b2f40:821d003c:0027688e:a70977ec
         Events : 0.1

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
       2       8       33        2      active sync   /dev/sdc1
       4       8       49        3      spare rebuilding   /dev/sdd1

And it seems there are only 3 active devices, with one spare.

Is it just me, or something wrong here?

share|improve this question
    
seems like you're missing some info –  Matt Rogish Jul 21 '09 at 15:08
    
Yeah, pressed enter too soon :-) Here is the entire question. –  Yannick Motton Jul 21 '09 at 15:13
add comment

4 Answers 4

up vote 9 down vote accepted

This tutorial covers building a raid5 array with mdadm. You can't use raid5 with less than three devices.

What do you mean by a spare? Raid5 is designed to provide redundancy to survive the failure of one device. If it doesn't do that then it isn't raid5 anymore.


Edit after question edit:

   When creating a RAID5 array, mdadm will automatically create a degraded
   array with an extra spare drive.  This is because  building  the  spare
   into a degraded array is in general faster than resyncing the parity on
   a non-degraded, but not clean, array.  This feature can  be  overridden
   with the --force option.

That seems to be it, mdadm is setting up the new array as degraded with a spare, and then putting the spare in to build the array.

share|improve this answer
    
Yes, but apart from the parity info distributed under the 4 drives, it seems it is talking about a spare drive. (Active: 3, Working: 4, Spare Devices: 1) And I am wondering if something is wrong... –  Yannick Motton Jul 21 '09 at 15:17
    
Also, as you can see in the tutorial you linked, /proc/mdadm suggest the 3 drives are all fine [UUU] whereas my array says one isn't active [UUU_]. I was fearing a faulty drive, but it seems it is spare. –  Yannick Motton Jul 21 '09 at 15:20
    
Nothing to worry about then. Thanks :-) –  Yannick Motton Jul 21 '09 at 15:24
    
This is not correct, see my post below. You can create a degraded RAID5 with 2 drives. You can also create a RAID5 with two members (--level=5 --raid-devices=2 ...). In cat /proc/mdstat it'll say it's using RAID5, but it'll behave like a RAID1 (e.g. you'll see UU and not UU_). –  sabujp Oct 23 '12 at 21:21
add comment

if you got clean disks, and you are making a brand new array, the faster option around the initial rebuild is

(in my case)

mdadm --create --verbose --force --assume-clean /dev/md0 --level=5 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
share|improve this answer
    
In my case creating a brand new, clean array, was what I was actually looking for, and, actually, what I expected from mdadm to do in the first place. –  wireman Jan 24 '11 at 2:54
add comment

It also shows as currently recovering and your spare drive is showing rebuilding. I'd be interested to see what your output looks like after it finishes.

share|improve this answer
    
I will paste the output after it finishes. –  Yannick Motton Jul 21 '09 at 15:25
    
I just confirmed on a test box what I suspect you will see and that is that once the recovery is done, the fourth device will not be listed as a spare any more. Precisely as the answer above states. –  TCampbell Jul 21 '09 at 15:34
add comment

If you want to create a degraded RAID5 from known clean disks/partitions you need at least 2 drives (e.g. for a 3 drive RAID5), you'd do :

mdadm --create --verbose --force --assume-clean /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 missing
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.