Grub re-install

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s