Thursday 17 January 2013

Dealing with GRUB issues

If the system has issues with GRUB configuration file, mostly due to incorrect entries in the GRUB configuration file or installation of another OS or due to a change in hardware. In this case you will end up in a screen of grub prompt.

Don't get panic, lets start the troubleshooting. Use the following commands:
===
grub > find /grub/grub.conf
O/p:  (hd0,3)
         (hd1,4)
===

This o/p means that there are two /boot partitions, probably due to multiple OS installation or software RAID.

(hd0,3) means that first hard disk fourth partition has a /boot.
(hd1,4) means that second hard disk fifth partition also has /boot.

To reinstall grub to the first instance of MBR:

====
grub >  root ( hd0,3)
grub >  setup (hd0)
====

Suppose, if you have ubuntu installed in the server then there is a menu.lst file not grub.conf.

In such case lets analyze the output :
===
grub > find /grub/grub.conf
(hd0,0)
grub > find /grub/menu.lst
find /grub/menu.ls
(hd0,0)
(hd0,1)
===

The o/p means that there are two /boot in the server. The first one in /dev/sda1 and the second one is in /dev/sda2. That is the first one is in first hard disk first partition and the second one is in first hard disk second partition.

To see the contents of grub.conf just use "cat" command as follows:
====
grub> cat (hd0,0) /grub/grub.conf
  ... contents of file listed ...
grub> cat (hd0,1) /grub/menu.lst
  ... contents of file listed ..
====

If the result is nothing, then this means that /boot is not a separate partition and it is a part of root partition. So, you have to use the following command:
====
grub > find /boot/grub/grub.conf
(hd0,1)
(hd1,5)
====

This means that one of the grub is in sda2 and the other one is in sdb6.

To restore the second instance and write the GRUB bootloader on the MBR of the first disk:
====
grub> root ( hd1,5)
grub>setup (hd0)
====

If in doubt as to where the root partition is located one might try to find a file in /etc. For example:
=====
grub > find /etc/fstab
( hd0,1)
====

This means that "/" partition is in /dev/sda2 in case of SATA or SCSI hard drives and for PATA it is /dev/hda2


         

No comments:

Post a Comment

Note: only a member of this blog may post a comment.