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 have a CentOS setup with sw RAID5 that holds my data. Well, the server died, so I bought another box to migrate my drives to. Only thing is, I cannot get the RAID array rebuilt (not even sure it needs rebuilding, might just need the /dev/md0 mapping created... but I don't even know how to determine what I need!)

Some details:

  • RAID5 software (used mdadm)
  • 4x 250GB drives (2 are SATA, 2 are EIDE -- would this matter? It worked fine in the other box...)
  • latest CentOS distro
  • built using mdadm

I've got a decent amount of experience with standard linux stuff, but the hardware level stuff runs me in circles. I've spent some time googling and elsewhere here on SF, so please be kind for my newbie questions :).

My question is this: how can I diagnose the problem? For all I know, I'm using the wrong device blocks when I try to rebuild the array, but I can't find the command to display only the devices that have some physical attachment.

Is there some simple way for me to run mdadm, having it scan over all my physical drives, and say "hey, drives 2,5,6,7 are a software array, want me to mount it?"

I basically just took the drives from my old box and put it into my new one. They show up in the BIOS. What steps do I need to take in order to get the array up, running, and mounted?

Thanks in advance!

share|improve this question

1 Answer 1

up vote 5 down vote accepted

If you don't have backups of the data then you should proceed with caution. None of this is particularly difficult, but it's certainly worth it to move slowly and with deliberation if it's a single-copy of your data. You can easily trash your data if you do the wrong thing.

In theory, the mdadm --assemble --scan --auto-update-homehost command will do what you want. It will blindly attempt auto-assembly and updates to any detected arrays. If you have a backup of the array and don't mind living a bit dangerously you can try this.

If you want to do things "by hand" you'll first need to locate all the devices the array is stored on. You can look at the output of dmesg to find the devices. Look for entries like hdg: 488397168 sectors (250059 MB) .... You should be able to identify all the devices attached to the system.

Use the fdisk -l command to display the partitions on the disk. Here's some sample output:

[root@srv02 ~]# fdisk -l

...

Disk /dev/hdg: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdg1               1       30401    24961765   fd  Linux raid autodetect

...

I clipped the output to show a single sample device (a 250GB disk with a single Linux software RAID partition on it). You should see several devices' partition tables listed.

You can examine the superblock on the partition with the mdadm --examine device command, like:

[root@srv02 ~]# mdadm --examine /dev/hdg1
/dev/hdg1:
          Magic : a92b4efc
        Version : 00.90.00
           UUID : 3c8b281e:715ce6bb:39297707:3bc149b6
  Creation Time : Mon Dec 17 17:28:35 2005
     Raid Level : raid5
  Used Dev Size : 243593472 (232.31 GiB 249.44 GB)
     Array Size : 1217967360 (1161.54 GiB 1247.20 GB)
   Raid Devices : 6
  Total Devices : 6
Preferred Minor : 1

    Update Time : Mon Mar 22 20:45:56 2010
          State : clean
 Active Devices : 6
Working Devices : 6
 Failed Devices : 0
  Spare Devices : 0
       Checksum : 6d966f24 - correct
         Events : 0.10988

         Layout : left-symmetric
     Chunk Size : 256K

      Number   Major   Minor   RaidDevice State
this     1      34        3        1      active sync   /dev/hdg1

   0     0      33        3        0      active sync   /dev/hde1
   1     1      34        3        1      active sync   /dev/hdg1
   2     2      56        3        2      active sync   /dev/hdi1
   3     3      57        3        3      active sync   /dev/hdk1
   4     4      88        3        4      active sync   /dev/hdm1
   5     5      89        3        5      active sync   /dev/hdo1

You can see that the devices for all of the component volumes of the array have been written in the superblock. Your new installation probably isn't assigning the same devices to the volumes such that the array isn't being auto-assembled.

Examine all the partitions that you expect to be part of the RAID set as per the above. All the component volumes of a given array will have the same UUID. Once you've located all the pieces, re-assemble the array using the mdadm --assemble command, writing the new devices back to the superblock as follows (replacing /dev/mdX with the MD device you'd like the array to be assembled as, and /dev/partition0, etc, with the member volumes of the array):

mdadm --assemble --update=homehost /dev/mdX /dev/partition0 /dev/partition1 ... /dev/partition6

That'll reassemble the array and update the superblock with the new hostname and devices. After you do that, you can cat /proc/mdstat to see the condition of the array. Finally, you can mdadm --detail --scan >> /etc/mdadm.conf to write the details of the array to the /etc/mdadm.conf file.

share|improve this answer
    
Wow, Evan, thank you very much! There is more detail in there than I've been able to piece together in a few days' worth of searching. This is a lone copy (I'm an idiot) so I will try out the manual suggestions first. I really appreciate your response, and will update this page tomorrow with my results. –  Travis Leleu Mar 23 '10 at 2:01
    
@leleu: "Idiot" may be a bit harsh, but certainly get a backup as soon as you're able. –  Evan Anderson Mar 23 '10 at 2:08
    
Evan, worked like a charm, thanks! And I've already got a backup in place (and tested as a replacement) –  Travis Leleu Mar 24 '10 at 4:05

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.