Friday, May 6, 2011

Install Grub On Second disk RAID 1

Hi just share with you guys, how to repair your Grub and your Raid, if your SDA1 is broken under the software raid, the os is CentOS 5.4


If you machine is totally can't boot up, please bring the CentOS installer disk.


boot: linux rescue --> go in to rescue mode


chroot /mnt/sysimage --> mount your disk


To check the GRUB :


cat /boot/grub/device.map

grub-install --recheck /dev/sdb
grub-install /dev/sdb





hopper:~# grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

grub> quit



sfdisk -d /dev/sda > sda.table -> to copy your partition table



sfdisk /dev/sda < sda.table -> to restore your partition table


Now take a look your md driver first.
#cat /proc/mdstat




Personalities : [raid1]
md0 : active raid1 sdb2[2](F) sda2[0]
      4192896 blocks [2/1] [U_]
    
md2 : active raid1 sdb3[2](F) sda3[0]
      479998016 blocks [2/1] [U_]
    
md1 : active raid1 sdb1[2](F) sda1[0]
      4192832 blocks [2/1] [U_]

The result on the top is explain that sdb is broken.

mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2
mdadm --detail --scan >> /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
mdadm --fail /dev/md0 /dev/sda1
mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
mdadm --add /dev/md0 /dev/sdb1



Regards,
феникс