How do I manually install GRUB? [duplicate]

I was installing Ubuntu 11.10 and the bootloader install failed. I tried installing it again but it didn't work so I want to know how to install grub manually. Thanks.


Solution 1:

I think this technique will not work. Because you don't know in which position you installer crashed. Check your disk first.

If you want to install grub manually then: Login using livecd. Open terminal, login as root:

sudo -i

find out your linux disk :

fdisk -l

mount it:

mount /dev/sdaX /mnt

Recover:

grub-install --root-directory=/mnt /dev/sda

For more information http://shantanucse.blogspot.com/2011/10/how-to-recover-ubuntu-904-or-higher.html

Solution 2:

In certain cases sudo update-grub might not work - it happened to me when installing Debian beside Ubuntu.

In such a case I do one of the following:

  • Create a live CD/USB of Ubuntu Secure Remix, which is an Ubuntu live with supplementary rescue tools, boot from that and use Boot Repair.

  • If you already have a regular Ubuntu live iso, create live usb with UNetbootin, live boot from that and install Boot Repair

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update

sudo apt-get install -y boot-repair && boot-repair &

(But apt-get update on a live USB might involve updates that take some time - and are also useless if the live usb is not persistent - so I recommend the first solution.)

Using Boot Repair to fix/reinstall GRUB is simple, just choose default/recommended repair option; more details here.