Rebuilding software RAID without mdadm.conf

Austing PowersRebuilding software RAID array is very easy when you have your mdadm.conf file at hand, but when you find yourself in a situation without backup of that little config file, e.g. after reinstalling the system or when your migrate disks to the new server, it can be a bit daunting.

Recently I had to reassemble two software RAID1 arrays one small Debian server after OS reinstall. So, there were four hard drives in total and to avoid mix-up and data loss, I had to find out which disk belonged which RAID array. Examining each drive with mdamd provided me with the necessary information.

 

 

root@localhost:~# mdadm --examine /dev/sdd1 
/dev/sdd1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : a4efd493:632caec4:50789581:e67b9b47
           Name : localhost:RA2  (local to host localhost)
  Creation Time : Wed Mar  4 19:26:05 2015
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 11720780943 (5588.90 GiB 6001.04 GB)
     Array Size : 5860390272 (5588.90 GiB 6001.04 GB)
  Used Dev Size : 11720780544 (5588.90 GiB 6001.04 GB)
    Data Offset : 262144 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : b5e2af07:edc086ce:c54c1952:b360835f

    Update Time : Sun Aug  2 13:24:02 2015
       Checksum : 714f53f - correct
         Events : 81709


   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing)
root@localhost:~# mdadm --examine /dev/sde1 
/dev/sde1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : a4efd493:632caec4:50789581:e67b9b47
           Name : localhost:RA2  (local to host localhost)
  Creation Time : Wed Mar  4 19:26:05 2015
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 11720780943 (5588.90 GiB 6001.04 GB)
     Array Size : 5860390272 (5588.90 GiB 6001.04 GB)
  Used Dev Size : 11720780544 (5588.90 GiB 6001.04 GB)
    Data Offset : 262144 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : ca0d4119:7d0ffe70:eeda4f58:f9b5cf56

    Update Time : Sun Aug  2 13:24:02 2015
       Checksum : b8a05254 - correct
         Events : 81709


   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing)

The key information I was looking for was array UUID. When I found the two disks with the same array UUID, I was able to create new MD device and assemble the RAID array.

root@localhost:~# mdadm --assemble --uuid=759f3216:695cc07c:5cba12b0:bd0a9e49 --verbose /dev/md0 /dev/sdd1 /dev/sde1
mdadm: looking for devices for /dev/md0
mdadm: /dev/sdb is identified as a member of /dev/md0, slot 0.
mdadm: /dev/sdc is identified as a member of /dev/md0, slot 1.
mdadm: added /dev/sdd1 to /dev/md0 as 1
mdadm: added /dev/sde1 to /dev/md0 as 0
mdadm: /dev/md0 has been started with 2 drives.

Checking array details confirmed that everything was in order.

root@localhost:~# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Mar  4 19:26:05 2015
     Raid Level : raid1
     Array Size : 5860390272 (5588.90 GiB 6001.04 GB)
  Used Dev Size : 5860390272 (5588.90 GiB 6001.04 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Sun Aug  2 13:24:02 2015
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost:RA2  (local to host localhost)
           UUID : a4efd493:632caec4:50789581:e67b9b47
         Events : 81709

    Number   Major   Minor   RaidDevice State
       0       8       49        0      active sync   /dev/sdd1
       2       8       65        1      active sync   /dev/sde1

Of course, updating mdadm.conf with reassembled array mustn't be forgotten.

root@localhost:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Also, make sure to take care of your mount definitions in /etc/fstab.

Category: 

No comments available.

Add new comment