You might need to reinstall the boot loader to the master boot record (MBR) if it becomes corrupted or erased. This can occur for example if Windows is installed on another partition which overwrites the MBR.
There are two ways to reinstall grub, automatically using grub-install, and manually through grub itself. grub-install is a script which calls grub underneath and in most cases it is your best solution. Sometimes the manual approach is better if you have a complex setup or the first option fails.
The GRUB naming scheme for hard drives and partitions is a bit confusing at first. Hard drive and partition numbers are ordererd with the count starting at zero. They are ordered based on the boot sequence in BIOS, so different types (IDE, SCSI, or RAID) my be intermixed.
For example a system with 2 PATA disks and 1 SATA disk might have the following drive mapping.
/dev/hda = (hd0) = drive 1
/dev/hda1 = (hd0,0) = drive 1, partition 1
/dev/hdb2 = (hd1,1) = drive 2, partition 2
/dev/sda1 = (hd2,0) = drive 3, partition 1
These steps require root privileges so switch to root or use sudo.
Install automatically with grub-install. The first argument is the hard drive where the boot loader will installed onto the MBR. It will use your current root directory partition for the rest of the installation. Change “/dev/sda” to the correct device for your system.
# grub-install /dev/sda
If you have a separate boot partition use the –root-directory option to install GRUB on that device instead of your root partition.
# grub-install --root-directory=/boot /dev/sda
The second method will allow you to install the boot loader manually with grub. Start by launching the GRUB command shell.
# grub
If your not sure of the device to specify for the installation, you can ask GRUB to tell you. Run this command and GRUB will attempt to find your GRUB installation on all available device partitions on the system. If found GRUB will output all the partitions containing GRUB installations in GRUB naming format. You can select the correct device and use in the next step.
grub> find /boot/grub/menu.lst
(hd0,0)
Set your root partition which contains the boot directory as well as the GRUB installation. You can use the output from the step above.
grub> root (hd0,0)
Install GRUB to the MBR of your first hard drive device.
grub> setup (hd0)
Exit Grub.
grub> quit
Reboot, you should hopefully see the menu on start up.
# reboot