Reinstalling GRUB and getting back your Operating Systems in Ubuntu
Installing a Microsoft Windows beside your Ubuntu, or maybe Upgrading your Ubuntu box to the latest version. Lots of reason and the same result, you can’t access your OSs.
The solution is almost always easy, it is just reinstalling your bootloader.
What is a bootloader:
- It is a small program that runs before any operating system is running, bootloaders are used to let you choose which operating system to boot in case you have more than one installed on your machine.
What is GRUB :
GRUB stands for : “GNU GRand Unified Bootloader) and it is a bootloader package from the GNU project
Click to Enlarge
For whatever a reason GRUB can fail and maybe loses its MBR file and then it doesn’t know where to get the OS from in the Harkdisk, this can happen maybe when you install Windows alongside Ubuntu, and it happened to me once when I upgraded my Ubuntu distribution to the latest edition. But for whatever reason, there is a solution and you can get your machine up and running again in less than 15 min.
- The Graphical way
Boot-Repair:
Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Ubuntu like when you can’t boot Ubuntu after installing Windows or another Linux distribution, or when you can’t boot Windows after installing Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.
Boot-Repair lets you fix these issues with a simple click, which (generally reinstalls GRUB and) restores access to the operating systems you had installed before the issue.
Getting Boot-Repair
1st Option: get a CD including Boot-Repair
The easiest way to use Boot-Repair is to burn one of the following disks and boot on it.
- Boot-Repair-Disk is a CD starting Boot-Repair automatically. (English only, 32&64bits compatible).
- Boot-Repair is also included in Ubuntu-Secured-Remix (multi-languages)
Remark : you can also install the ISO on a live-USB (eg via UnetBootin, LiliUSB or MultiSystem).
2nd Option: install Boot-Repair in Ubuntu
Obviously this will be done on a Live-CD or a Live-USB.
Open the Terminal (Ctrl + alt + T) and enter :
|
1 2 |
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update sudo apt-get install -y boot-repair && boot-repair |
Note : Boot-Repair PPA packages are available for Ubuntu 10.04, 10.10, 11.04, 11.10 and 12.04.
Using Boot-Repair:
Recommended Repair
- launch Boot-Repair from either :
- the dash (Unity)
- System->Administration->Boot-Repair menu (Gnome)
- by typing ‘boot-repair’ in a terminal
- Then try “Recommended repair” button. When repair is finished, note the URL that appeared on a paper, then reboot and check if you recovered access to your OSs.
If the repair did not succeed, indicate the URL to people who help you by email or forum.
Advanced Options
- The Terminal Way
Open the Terminal (Ctrl + alt + T) and type in :
|
1 |
sudo grub-install /dev/XXX |
Where XXX is the device of which your Ubuntu installation is on. (e.g: grub-install /dev/sda).
Note : You can also use /dev/disk/by-label/ if the partition you installed on has a label. You can determine the /dev node for such a device by running:
|
1 |
ls -l /dev/disk/by-label/ |
This will give you something like :
|
1 2 3 4 5 6 7 |
lrwxrwxrwx 1 root root 10 Oct 16 10:27 data -> ../../sdb2 lrwxrwxrwx 1 root root 10 Oct 16 10:27 data2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Oct 16 10:27 fat -> ../../sda6 lrwxrwxrwx 1 root root 10 Oct 16 10:27 home -> ../../sda7 lrwxrwxrwx 1 root root 10 Oct 16 10:27 root -> ../../sda1 lrwxrwxrwx 1 root root 10 Oct 16 10:27 swap -> ../../sda5 lrwxrwxrwx 1 root root 10 Oct 16 10:27 windows -> ../../sdb1 |
You can also use fdisk if you do not see the /dev/disk/by-label:
|
1 |
sudo fdisk -l |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$ sudo fdisk -l Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0001bc54 Device Boot Start End Blocks Id System /dev/sda1 * 1 18725 150403072 83 Linux /dev/sda2 18725 19458 5884929 5 Extended /dev/sda5 18725 19458 5884928 82 Linux swap / Solaris Disk /dev/sdb: 15.1 GB, 15103033344 bytes 64 heads, 32 sectors/track, 14403 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00068852 Device Boot Start End Blocks Id System /dev/sdb1 * 1 14403 14748656 c W95 FAT32 (LBA) |
From here, find only the drive name, ignore the partition number, that is, for partitions labeled “root”, “data2″, “fat”, “home” and “swap” it’s all still just sda. This is due to the fact that GRUB is installed in the MBR of the drive, and not on a partition.
- Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold Left Shift while booting. You will be able to choose between Ubuntu and Windows.
Hope this Helps .. If you have any Question please write in the Comments ..




















