Recovering from a disk failure with Linux-raid mirrored disksby Mark FosterMarch 13th, 2003
WARNING! This article is sorely outdated, please see this link for an update that is both current and useful!This article presents the steps I used to recover from a hard drive failure while running software RAID1 (mirrored drives) on Red Hat Linux.
Environment
SituationThe first drive sda has failed and the software raid is running in "degraded" mode, as shown in the output of/proc/mdstat . There is one mirrored partition (sda5 -=- sdb5) and a swap partition on each drive (sda1 and sdb1).
PreparationRead up on software RAID (see References below)Since sdb was identical to sda, we can use it's partition table as reference.
You'll need a boot floppy - use Examine and understand the output of the following commands: sfdisk -l /dev/sdb cat /etc/raidtab cat /proc/mdstat ProcessDump the partition table to a file suitable to feed back to sfdisk.[root@host1 ~]# sfdisk -d /dev/sdb > /tmp/sdb.out [root@host1 ~]# mv /tmp/sdb.out /tmp/sda.inEdit the file, changing sdb to sda in the first column. [root@host1 ~]# vi /tmp/sda.inNow let's re-create the partition table on sda. [root@host1 ~]# sfdisk /dev/sda < /tmp/sda.inAdd sda5 back into the mirror device md0. [root@host1 ~]# raidhotadd /dev/md0 /dev/sda5Check out the result in /proc/mdstat , you should see that recovery is underway.
[root@host1 ~]# cat /proc/mdstatReactivate our swap space. [root@host1 ~]# mkswap /dev/sda2 [root@host1 ~]# swapon -aVerify the swap partition is back online [root@host1 ~]# swapon -sOnce recovery is complete, run lilo to recreate the MBR on /dev/sda [root@host1 ~]# /sbin/lilo -vNote that this will likely not work on Red Hat 7.2 and above since the default boot loader was made grub... but if you upgraded from 7.1 your system might still be using lilo. Voila! Reboot if you like although this is not strictly necessary [root@host1 ~]# reboot ConclusionThe key to a successful recovery is keeping a level head and do not panic. Thesfdisk -d command is wonderful for recreating the partition layout. It should prove just as useful for a RAID5 recovery, but I cannot attest to that personally.
If I was helpful, please take a moment to let me know. Referencesman pages:mkbootdisk(8) sfdisk(8) swapon(8) mkswap(8) raidtab(5)
![]() If I was helpful, please let me know.
|
|