You are Here: FAQ ->Dedicated Servers->Linux Root Server->Recovery Tool->Article #10


Software raid rebuild with grub


-----------------------------------------------------------------------------------
*Product:* Root business class servers
*Issue:* Business class Root servers use software raid1, these drives are mirrored so that if one fails data is not lost.
Unlike hardware raid, software raid is not rebuilt automatically after a failed hard disk has been replaced.
The following solution must be performed within the rescue system.
-----------------------------------------------------------------------------------

*This example demonstrates rebuilding the sofware raid on device /dev/sdb*

First take a look at the partition structure on the good disk

#fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 1 123 987966 fd Linux raid autodetect
/dev/sda2 124 367 1959930 82 Linux swap / Solaris
/dev/sda4 368 19457 153340425 5 Extended
/dev/sda5 368 976 4891761 fd Linux raid autodetect
/dev/sda6 977 1585 4891761 fd Linux raid autodetect
/dev/sda7 1586 19457 143556808+ fd Linux raid autodetect


You will need to duplicate the partitons of the good disk on /dev/sdb

#fdisk /dev/sdb (follow the menu options) m for help p for partition list n new partition t type w write to disk

Alternatively you can run
#sfdisk -l -uS -d /dev/sda | sfdisk /dev/sdb (this can delete all partitions on the good disk if you do it wrong)

Set the swap:
#mkswap /dev/sda2
#mkswap /dev/sdb2
#swapon -p 1 /dev/sda2
#swapon -p 1 /dev/sdb2

Check the details of the raid:
#less /proc/mdstat

Once you have the new disk partitioned exactly as the good disk, you can begin adding it to the raid using the info from /proc/mdstat

~Example Only~
#mdadm /dev/md1 --add /dev/sdb1
#mdadm /dev/md5 --add /dev/sdb5
#mdadm /dev/md6 --add /dev/sdb6
#mdadm /dev/md7 --add /dev/sdb7


Next, make sure that the mount tab and file system tab correspond with the raid configuration, if not then edit:
#mount /dev/md1 /mnt
#less /mnt/etc/mtab
#less /mnt/etc/fstab

Mount the rest of the partitions and chroot:
~Example~
#mount -t proc none /mnt/proc
#mount /dev/md5 /mnt/usr
#mount /dev/md6 /mnt/home
#mount /dev/md7 /mnt/var
#chroot /mnt

Configure grub:
#grub
grub>device (hd0) /dev/sda
grub>root (hd0,0)
grub>setup (hd0)
grub>device (hd1) /dev/sdb
grub>root (hd1,0)
grub>setup (hd1)
grub>quit

Exit the chroot and check the progress of the resync:
#exit
#less /proc/mdstat

You want to see [2/2] [UU] for each one.
md1 : active raid1 sdb1[0] sda1[1]
987840 blocks [2/2] [UU]


Once the resync is finished, umount the drives and boot to local:
#umount -al


Print Article
How useful was this article?
(From 5 = Very Useful to 1 = Not useful at all):
1 2 3 4 5