HOW TO: Re-install Grub2
Has it happened to you that you install Windows after you installed Ubuntu and your machine does only boot Windows and doesn’t give any sign of Ubuntu?
Or have you installed Ubuntu after you installed Windows and you try to boot and the only screens that appears is a prompt with “grub>” ?
Well the answer is just: RE-INSTALL GRUB2 !!!
What normally happens, is that there is a conflict between Grub and MBR (Master Boot Record) from Windows, they both want to be the “oficial” boot loader.
First of all, what is Grub and MBR? Well basically it is a part in the hard disk (at the beginning of the disk) that contains the information about the boot (and more information, if you want a detailed information about MBR check here)
How to Re-install Grub2?
What do we need?
- Linux Live CD (in this case we will use Ubuntu 10.10)
How to get it?
- Follow this tutorial on how to get the Ubuntu Live CD
Now that we have the tools necessary, let’s start:
Boot the live CD and open a terminal with Ctrl+Alt+T
Now in the console:
Get root privileges:
Check where Ubuntu is installed.
It should appear something similar to this:
In this case my Ubuntu is installed in the partition ‘/dev/sda5′. You have to check where your partition of Linux is.
Now we will create some directories. Remember, you have to do this as root!
mkdir /mnt/reinstall mkdir /mnt/reinstall/dev mkdir /mnt/reinstall/proc mkdir /mnt/reinstall/sys
Now we have to use what we got from ‘fdisk -l’. Do you remember where your Ubuntu was installed?
mount /dev/sda5 /mnt/reinstall mount --bind /dev /mnt/reinstall/dev mount --bind /proc /mnt/reinstall/proc mount --bind /sys /mnt/reinstall/sys chroot /mnt/reinstall
Now we are at the shell of /dev/sda5 . Exactly as if we had boot our Ubuntu from the Hard disk.
The only missing is: REINSTALL GRUB!!
How to do it?
grub-install /dev/sda update-grub
Notice that in this case we DO NOT USE /dev/sda5 !!! We used /dev/sda because is the name of the hard disk! (/dev/sda5 is the name of the partition)
Exit your console and reboot. Your Grub2 is now installed!!! Congratulations!!