cat /proc/mdstat
returns:
Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sde[4] sdd[2](F) sdc[1] sdb[0] 3144192 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UU_U] unused devices:
NOTE: The (F): Indicates the /dev/sdd device has failed.
mdadm --detail /dev/md0
returns:
/dev/md0: Version : 1.2 Creation Time : Tue Sep 6 18:31:41 2011 Raid Level : raid5 Array Size : 3144192 (3.00 GiB 3.22 GB) Used Dev Size : 1048064 (1023.67 MiB 1073.22 MB) Raid Devices : 4 Total Devices : 4 Persistence : Superblock is persistent Update Time : Thu Sep 8 16:14:21 2011 State : clean, degraded Active Devices : 3 Working Devices : 3 Failed Devices : 1 Spare Devices : 0 Layout : left-symmetric Chunk Size : 512K Name : raidtest.loc:0 (local to host raidtest.loc) UUID : e0748cf9:be2ca997:0bc183a6:ba2c9ebf Events : 75 Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 2 0 0 2 removed 4 8 64 3 active sync /dev/sde 2 8 48 - faulty spare /dev/sdd
mdadm --manage --remove /dev/md0 /dev/sdd
returns:
mdadm: hot removed /dev/sdd from /dev/md0
This allows you to refer to your documentation to know which bay the failed disk in in.
smartctl -a /dev/sdd | grep -i serial
returns:
Serial Number: VB455d882e-8013d7c9
Physically remove the failed drive.
Replace this failed drive with a new one.
Add the replacement drive to the array:
mdadm --add /dev/md0 /dev/sdd
returns:
mdadm: added /dev/sdd
mdadm --detail /dev/md0
returns:
/dev/md0: Version : 1.2 Creation Time : Tue Sep 6 18:31:41 2011 Raid Level : raid5 Array Size : 3144192 (3.00 GiB 3.22 GB) Used Dev Size : 1048064 (1023.67 MiB 1073.22 MB) Raid Devices : 4 Total Devices : 4 Persistence : Superblock is persistent Update Time : Thu Sep 8 17:03:44 2011 State : clean, degraded, recovering Active Devices : 3 Working Devices : 4 Failed Devices : 0 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Rebuild Status : 36% complete Name : raidtest.loc:0 (local to host raidtest.loc) UUID : e0748cf9:be2ca997:0bc183a6:ba2c9ebf Events : 85 Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 5 8 48 2 spare rebuilding /dev/sdd 4 8 64 3 active sync /dev/sde
NOTE: Wait for the RAID to rebuild.
WARNING: If another drive fails before the point a new drive is added and the rebuild is complete, it could result in all data being lost!
There are several ways around this:
mdadm --add /dev/md0 /dev/sdf
returns:
mdadm: added /dev/sdf
mdadm --grow /dev/md0 --level=6 --raid-devices=5 --backup-file=/root/backup
returns:
mdadm level of /dev/md0 changed to raid6
NOTE: Notice the backup-file argument.
Ensure:
cat /proc/mdstat
returns:
Personalities : [raid6] [raid5] [raid4] md0 : active raid6 sdf[6] sdd[5] sde[4] sdc[1] sdb[0] 3144192 blocks super 1.2 level 6, 512k chunk, algorithm 18 [5/4] [UUUU_] [==>..................] reshape = 13.2% (139264/1048064) finish=4.4min speed=3373K/sec unused devices:
mdadm --detail /dev/md0
returns:
/dev/md0: Version : 1.2 Creation Time : Tue Sep 6 18:31:41 2011 Raid Level : raid6 Array Size : 3144192 (3.00 GiB 3.22 GB) Used Dev Size : 1048064 (1023.67 MiB 1073.22 MB) Raid Devices : 5 Total Devices : 5 Persistence : Superblock is persistent Update Time : Thu Sep 8 18:54:26 2011 State : clean Active Devices : 5 Working Devices : 5 Failed Devices : 0 Spare Devices : 0 Layout : left-symmetric Chunk Size : 512K Name : raidtest.loc:0 (local to host raidtest.loc) UUID : e0748cf9:be2ca997:0bc183a6:ba2c9ebf Events : 2058 Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 5 8 48 2 active sync /dev/sdd 4 8 64 3 active sync /dev/sde 6 8 80 4 active sync /dev/sdf
NOTE: If for whatever reason you want to go from 6 drives to 5, you can also do that.