Thursday, June 14, 2007

Restoring grub in MBR

There is a lot of stuff about this.

But of course none worked for me :-D.
So I decided to post a solution that worked ;-).
  1. Boot with any live CD (I've done it with Knoppix 3.x and Ubuntu)
  2. Prepare directory for mounting:
    $ sudo mkdir /mnt/ubuntu
  3. Mount the root (/) partition of ubuntu e.g.:
    $ sudo mount /dev/hda5 /mnt/ubuntu
  4. Mount proc and dev filesystems on mounted partition:
    $ mount -o bind /dev /mnt/ubuntu/dev
    $ mount -o bind /proc /mnt/ubuntu/proc
  5. If /boot is on seperate partition mount it:
    $ sudo mount /dev/hda4 /mnt/ubuntu/boot
  6. Chroot the mounted partition:
    $ chroot /mnt/ubuntu
  7. Populate /etc/mtab:
    $ sudo cp /proc/mounts /etc/mtab
  8. $ sudo grub-install /dev/hda
  9. Exit the shell
  10. Reboot
Hope that it'll help someone ;-)