linux/debian raid 1 recovery how-to
Today one of two harddisks on server fails. How-to repair raid? Easy.
Check raid status (find hda is not updated)
If damaged disk is active (for example: only bad sectors) remove it from raid.
mdadm /dev/md0 -r /dev/hda
Turn off your server if hd is not hot-swappable.
Remove damaged hd and replace it with new hd.
Restart your server, be sure that is starts from the old ok hd (ex. hdb). Sometimes bios doesn’t properly updates boot devices and tries to start from new hd or cds, fix it.
System must boot-up properly from old ok hd.
Clean new hd (ex. /dev/hda), remove all partitions.
Clean MBR of new disk (to be sure that an old mbr doesn’t exist)
dd if=/dev/zero of=/dev/hda bs=512 count=1
Copy raid partitions scheme from old ok hd.
sfdisk -d /dev/hdb > mbr_hdb.txt
Apply that scheme to your new hd.
sfdisk /dev/hda < /root/mbr_hdb.txt
Add partitions from new disk to your raid
mdadm /dev/md0 -a /dev/hda1
Raid recovery starts.
Check rebuild status
mdadm –detail /dev/md0
Version : 00.90
Creation Time : Wed Apr 1 11:10:50 2009
Raid Level : raid1
Array Size : 37110016 (35.39 GiB 38.00 GB)
Used Dev Size : 37110016 (35.39 GiB 38.00 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Fri May 8 11:52:58 2009
State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1
Rebuild Status : 74% complete
UUID : b1d86bee:0e4dedf0:4ddd5836:05672650
Events : 0.680998
Number Major Minor RaidDevice State
2 3 1 0 spare rebuilding /dev/hda1
1 3 65 1 active sync /dev/hdb1
Wait and be happy.
oh…. as you know this is not a complete/best/lucky tutorial, if you follow it you home may explode, your city my be destroyed, but don’t bother me! 🙂 no warranty
Good luck!! 😀
On 2TB drives this kind of remirroring will take finish in eternity.
if you change your drive you have to rebuild in any case… you don’t need to wait that rebuid finishes of course. you can use your pc like you do every day and you can also reboot without problems. rebuild restarts automatically after reboot… can you provide a better solution? It’s welcome!