Monday, December 26, 2011

How to recover GRUB of RHEL in a dual boot system


Before recovering the grub you need to know why it has been needed to re install the GRUB(Grand Unified Boot loader)?
>When you install windows after linux  the boot loader of the windows ie ntldr will be written on the MBR of the hard disk of the system due to which you need to re install the GRUB
>When you remove Linux in a dual boot system using the fixmbr command without removing the unused partitions of linux you can actually recover them  

There fore for recovering the grub of linux you have to follow these steps:
 Step 1:- Boot your system with a bootable linux/rhel dvd/cd
Step2:- Go to Rescue mode using linux rescue command
linux rescue

Step 3:-Choose installation language of your choice, i am choosing english as default

Select language to English

Step 3:-Choose keyboard of your choice

Select Keyboard layout to US

Step 4:-Press enter on continue and it will search for linux on hard disk




Step 5:- Select no on start networking tab



Step 6:- Select continue on Rescue page


mount-sysimage

Step 7:-Select ok



Step 8:- After that you will get  sh-0.3# 
 sh

Use fdisk -l to know the hard disk type

sh-3.2# fdisk -l
 
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1242     9976333+  83  Linux



Step 9:-Use chroot /mnt/sysimage to mount the installation directory under chroot enviourment
sh-0.3#  chroot /mnt/sysimage



Step 10:- Now install the grub on the hard disk using
sh-3.2#grub-install /dev/hda(sda for sata hard disk)



Now reboot your system, grub will successfully be installed on your system.