Booting Ubuntu From Grub Rescue

I have XP on another partition and it fails to load now.
When i start my machine I get the grub rescue command prompt.
!
Solution
:
!
Boot from live Cd. Open a terminal and enter :


grub-install

or

After booting the live CD, you have to bring up a terminal window in that go to the Applications,
Accessories, and then to Terminal, and then you got to verify what partitions you have by typing :

$sudo fdisk -l

In this your going to see two partitions, with the first being the MS Windows (NTFS)
partition
and the second being your Linux installation, And then when you will proceed:

$sudo grub
grub> root (hd0,1)
grub> setup (hd0)
grub> quit

If everything is going well, you should be able to reboot, remove the CD and boot into Ubuntu.
You can also make the adjustment by
/boot/grub/grub.cfg once in Ubuntu,
so that at boot time you can get the either of the operating system
.

Alternatively :

grub-install –root-directory /boot /dev/hda “hda = ubuntu partition, eg : sda9“


!
!
TheĀ update-grubĀ command is used to generate and update the /boot/grub/grub.cfg.
This will update grub file with Bootable partition finding.

I have a working solution currently successful on Ubuntu Natty v 11.10

Run the grub-setup command, inserting the -d option and specifying the path to the /boot/grub directory of the operating system you’re trying to fix,

sudo grub-setup -d /media/disk/boot/grub /dev/sda

The -d option tells GRUB to use files from the specified directory.

Please substitute the word ‘disk’ with the name of your own mount point.

The ‘/dev/sda‘ part tells grub-setup to install GRUB to MBR in the first hard disk, which is called ‘/dev/sda‘.

You may use the same command to install GRUB in any other disks in your computer by replacing the /dev/sda part of the command with /dev/sdb or /dev/sdc and so on.

– If the command fails with feedback about not being able to access a device.map file, you might need to try again and specify the exact device.
map file to use with the -m option.

grub-setup -d /media/04bbbd00-d0c4-4b5b-99e2-d9ca0259a1d2/boot/grub /dev/sda

sudo mount /dev/sda4 /mnt
sudo mount /dev/sda4 /mnt/boot
sudo grub-install –root-directory=/mnt /dev/sda