Migrated. Originally posted: 2010-01-02
I have found a few places on the net with info on re-installing grub.
Here is what worked for me:
- Boot with a Live CD. I used Ubuntu LTS (8.04). Commands are mostly run as root, which is shown here as sudo commands.
- Mount the root partition from your disk drive.
- I was mounting /dev/sda1, and chose to mount it on /mnt.
- sudo mount /dev/sda1 /mnt
- If needed, mount the /boot partition in the right place.
- sudo mount /dev/sda2 /mnt/boot
- No need to mount /home if it is a separate partition.
- Mount /dev from your host as /dev on the mounted root partition from the hard drive.
- Required to be able to find the drives once you chroot.
- sudo mount –bind /dev /mnt/dev
- “Change root” to /mnt. This means pretending you are running from the hard drive.And now I can merge the grub entry from the Centos 5 install that trashed grub for me when I was trying to set up a Xen host in dual boot mode.
- sudo chroot /mnt
- You are now the root user in the chroot environment.
- Install grub to the boot disk’s MBR.
- grub-install /dev/sda
- This is the normal case. If some other boot system is the primary one, you will need to install grub to wherever it was installed before, or wherever the primary boot system expects to find it.