Modern Linux use Grub2. As far as I know in any Linux terminal mode we can use grub-install to repair Grub2.
What you need to do is to first boot up a Linux CD or DVD. Run it to try out the Linux and not install it. You then get a terminal and use the command
if the Linux uses sudo like Ubuntu or
if you are in a root terminal like Debian
However you need to know the partition where Grub2 is residing, mount that partition and then specify which partition you want Grub2 to be installed.
If you have Linux in the 2nd partition of disk sda then it is /dev/sda2 and Grub2 is always in its /boot/grub
To have Grub2 files available from sda2 you use the following commands in a terminal (say in Ubuntu)
Code:
sudo mkdir /mnt/sda2
sudo mount /dev/mnt/sda2
ls /mnt/sda2/boot/grub
If you list the content of /mnt/sda2/boot/grub you will see all the Grub files including its configuration file /boot/grub/grub.cfg.
Now you can tell Grub its Grub partition and the the location Grub2 to be installed. Say let's put it in /dev/sda2 and also /dev/sda
Code:
sudo grub-install --force --boot-directory=/mnt/sda2/boot/grub /dev/sda2
The --force is to force GRub to install in a partition. It is not needed if it is the MBR which is /dev/sda without a partition number attached.
Code:
sudo grub-install --boot-directory=/mnt/sda2/boot/grub /dev/sda
Please note MBR (/dev/sda) is not the same as in /dev/sda1.
The --root-directcory parameter is to tell which Grub is to be installed because if you are booting several Linux each will have Grub in its own partition.
Grub2 does not like itself to be put in a position other the MBR so it always complains but will execute it if the --force parameter is used. It it still not working repeat the command again.
If Grub2 is in the MBR it will boot itself automatically.
If Grub2 is in a partition then it must be booted by another boot loader including another Grub2.
If you have a Grub2 floppy or CD boot it up and the Linux in sda2 can be fired up using these lines
Code:
set root=(hd0,2)
chainloader +1
boot
Each bootloader has the ability to repair itself. I never use hexedit to amend a bootloader.