Replace Disk in Linux MD RAID-5 Array – How to Guide

linuxmdadmraid5software-raid

I had some recent computer issues and somehow one of my disks ended up not being recognized in my array anymore. It identifies fine, and both smart and some other disk checking utils all say its fine, but somehow the UUID is different.

as a result, mdadm says there is a 'removed' disk. Ideally I'd like to just update it so that it detects it again, but since this is raid-5 I don't see why I couldn't just remove it from the array and then re-add it and let it rebuild.

unfortuntely every command I see wants me to refer to it as a device when removing it, but as far as md is concerned its just a uuid that is no longer available. How can I remove a disk that is currently set as "removed"?


Edit: More info, as requested. I'm currently running in an ubuntu live cd without networking, so these are hand typed. Sorry if theres any spacing issues.

/proc/mdstat:
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : inactive sdd1[0] sdc[3] sde1[1]
       3907034368 blocks

mdadm --detail /dev/md0
/dev/md0:
Version : 00.90
Creation Time : Wed May 26 22:59:21 2004
Raid Level : raid5
Used Dev Size : 976759936 (931.51 GiB 1000.20 GB)
Raid Devices: 4
Total Devices: 3
Prefered Minor : 0
Persistence: Superblock is persistent

Update Time: Sat Nov 27 1:03:17 2010
State : active, degraded, Not Started
Active Devices: 3
Working Devices: 3
Failed Devices: 0
Spare Devices: 0

Layout : left-symmetric
Chunk Size: 64K

UUID: 5a4d2b61:9c5c6ad5:aea414d0:5f8dbc13
Events: 0.2169805

Number Major Minor Raiddevice State
     0     8    49  0          active sync /dev/sdd1
     1     8    65  1          active sync /dev/sde1
     2     0    0   2          removed
     3     8    32  3          active sync /dev/sdc

Best Answer

Run the following commands on the removed device:

mdadm --zero-superblock /dev/sdXn
mdadm /dev/md0 --add /dev/sdXn

The first command wipes away the old superblock from the removed disk (or disk partition) so that it can be added back to raid device for rebuilding. Make sure that you run this command on the correct device!!