Ubuntu and many other Linux distributions use the GRUB2 boot loader. If GRUB2 breaks — for example, if you install Windows after installing Ubuntu or overwrite your MBR — you won’t be able to boot into Ubuntu.
You can easily restore GRUB2 from a Ubuntu live CD or USB drive. This process is different from restoring the legacy GRUB boot loader on older Linux distributions.
Graphical Method – Boot Repair
Boot Repair is a graphical tool that can repair GRUB2 with a single click. This is the ideal solution to boot problems for most users.
If you have the media you installed Ubuntu from, insert it into your computer and restart. If you don’t, download a Ubuntu live CD and burn it to a disc or install it on a USB flash drive. You can also download a dedicated Boot Repair live CD.
After booting into the live Ubuntu environment, open a terminal from the Dash and run the following commands to install Boot Repair:
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair
The Boot Repair window will appear after you run the boot-repair command. After it scans your system, click the Recommended repair button to repair GRUB2 with a single click.
You can also click the Advanced options header to customize GRUB2’s options without learning its command-line syntax.
Restart your computer after using the Boot Repair tool. Ubuntu should boot up normally.
If you’d rather get your hands dirty, you can do this yourself from a terminal. You’ll need to boot from a live CD or USB drive, as in the graphical method above. Ensure the version of Ubuntu on the CD is the same as the version of Ubuntu installed on your computer — for example, if you have Ubuntu 12.04 installed, ensure you use a Ubuntu 12.04 live CD.
Open a terminal after booting into the live environment. Identify the partition Ubuntu is installed on using one of the following commands:
sudo fdisk -l
Here’s the output of both commands. In the fdisk -l command, the Ubuntu partition is identified by the word Linux in the System column. In the blkid command, the partition is identified by its ext4 file system.
Run the following command to mount the Ubuntu partition at /mnt, replacing /dev/sdX# with the device name of your Ubuntu partition from the above commands:
sudo mount /dev/sdX# /mnt
For example, use /dev/sda1 for the first partition of the first hard disk device.
Important: If you have a separate boot partition, skip the above command and mount the boot partition at /mnt/boot. If you don’t know whether you have a separate boot partition, you probably don’t.
Run the following command to reinstall grub from the live CD, replacing /dev/sdX with the device name of the hard disk above. Omit the number. For example, if you used /dev/sda1 above, use /dev/sda here.
sudo grub-install –boot-directory=/mnt/boot /dev/sdX
Restart your computer and Ubuntu should boot properly.
For more detailed technical information, including how to use the chroot command to gain access to a broken Ubuntu system’s files and restore GRUB2, consult the Ubuntu wiki.