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've currently put together a new system and part of that has been creating a software RAID 5 using 'mdadm' in Ubuntu Server.

I successfully got to the point where I create the array using:

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

I left it to do its thing overnight then used the following command to check on it:

watch cat /proc/mdstat

To which the following was returned:

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdd1[4](S) sdc1[2] sdb1[1] sda1[0](F)
      5860535808 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/2] [_UU_]

unused devices: <none>

It appears that one has failed (and I'm not too savvy with why another is a spare).

So, just to be sure that something else isn't amiss I wanted to try and re-engage the failed drive. Can someone explain how I can do that and what I should do with the spare (if anything).

And also how do I know when synchronisation is complete?

The tutorial I used to get this far is located here:

Many thanks!

p.s. Here is some extra information that may help:

sudo mdadm --detail /dev/md0
        Version : 1.2
  Creation Time : Mon Jun 18 21:14:21 2012
     Raid Level : raid5
     Array Size : 5860535808 (5589.04 GiB 6001.19 GB)
  Used Dev Size : 1953511936 (1863.01 GiB 2000.40 GB)
   Raid Devices : 4
  Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Mon Jun 18 21:50:26 2012
          State : clean, FAILED 
 Active Devices : 2
Working Devices : 3
 Failed Devices : 1
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 512K

           Name : myraidbox:0  (local to host myraidbox)
           UUID : a269ee94:a161600c:fb1665e7:bd2f27b3
         Events : 13

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8       17        1      active sync   /dev/sdb1
       2       8       33        2      active sync   /dev/sdc1
       3       0        0        3      removed

       0       8        1        -      faulty spare   /dev/sda1
       4       8       49        -      spare   /dev/sdd1
share|improve this question

For some reason, mdadm decided that sda1 is faulty and sdd1 should be removed. Check /var/log/syslog for messages from mdadm or ATA/SCSI errors to try to find the reason. There may be something wrong with your drives or controllers.

To recover the array you need to re-add the failed drives. Hopefully mdadm will recognise the drives as previously being part of the array and having valid data. I would try the following with sda1 first, and then sdd1.

mdadm /dev/md0 --re-add /dev/sda1

If it complains about sda1 already being part of the array, remove it first and then re-add it. Check the output of mdadm --detail before continuing with the next drive.

share|improve this answer
Thanks for your prompt help! From the command you mentioned, I get back: Cannot open /dev/sda1: Device or resource busy AND Cannot open /dev/sdd1: Device or resource busy... Is there something I should be doing before this? – Stephen Jun 19 '12 at 7:51
@Stephen It sounds like either something else is using the device, or there is a hardware problem. Check your logs for signs of errors, and try using lsof to see if something has the device open. – mgorven Jun 19 '12 at 7:53

You must log in to answer this question.

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