Tuesday, March 13, 2018

Centos mdadm -- how to replace an already failed drive.   There is a TON of information on the web about mdadm.  My problem was that the config file didn't exist.  After I created that everything else jived with what I was reading. 

/dev/sdb failed

1. find out UUID and details of the array

Use --examine to look at an existing disk
mdadm --examine -v /dev/sde
output:

 Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : a94ed4cc:acd0f975:28f03379:fe085d38


There is the Array UUID

I didn't have a mdadm.conf file, so I had to create one (it's apparently optional and I didn't create one when I first build the raid).

mkdir /etc/mdadm/mdadm.conf (this is where centos keeps it I believe)
Add these lines and make sure all others are commented out

DEVICE /dev/sdb /dev/sdc /dev/sdd /dev/sde
ARRAY /dev/md0 UUID=a94ed4cc:acd0f975:28f03379:fe085d38



My array has 4 drives as you can see

Start the array ( you might have to stop it first)
mdadm --assemble /dev/md0 --scan --force


Re-start the array (force it) and add the drive that you've replaced

mdadm: Marking array /dev/md0 as 'clean'
mdadm: /dev/md0 has been started with 3 drives (out of 4).
[root@localhost ~]# mdadm --manage /dev/md0 --add /dev/sdb
mdadm: added /dev/sdb


Bingo!

mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon Feb 29 01:02:46 2016
     Raid Level : raid5
     Array Size : 2929893888 (2794.16 GiB 3000.21 GB)
  Used Dev Size : 976631296 (931.39 GiB 1000.07 GB)
   Raid Devices : 4
  Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Tue Mar 13 07:25:23 2018
          State : clean, degraded, recovering 
 Active Devices : 3
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 512K

 Rebuild Status : 0% complete

           Name : user-S5000PSL-2:my-raid
           UUID : a94ed4cc:acd0f975:28f03379:fe085d38
         Events : 3569

    Number   Major   Minor   RaidDevice State
       5       8       16        0      spare rebuilding   /dev/sdb
       1       8       32        1      active sync   /dev/sdc
       2       8       48        2      active sync   /dev/sdd
       4       8       64        3      active sync   /dev/sde

No comments:

Post a Comment