If you aren’t a Linux user this won’t make much sense to you, but feel free to read along anyway. In most cases when we install 2 or more operating systems and Linux is one of them we opt to install Linux second. This is because it writes the menu at the beginning from which we select the operating system to use.
Grand Unified Boot Loader (Grub for short)
However there are times when we may need to repair the grub, such as following a reinstallation of Windows in a dual boot configuration.
There are several methods of doing this and I’ll list them from simplest to most involved:
- Booting into the live installation media of your Linux distribution and running a boot repir program.
Obviously booting in to a Ubuntu or Mint distro typically doesn’t give much room to write programs, however it does allow us with sufficient privileges to correct the bootloader.
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update sudo apt-get install -y boot-repair && boot-repair
After entering your administrative password you’ll be prompted to select from options which include:
Use Recommended Repair
And after that you should find your bootloader in perfect working order. However for non Ubuntu/Mint users there are 2 more methods which need mentioning.
These were all collected from Linux forums i.e. Ubuntu forums etc and should work great. (Fair credit to the users who posted these!)
- Boot from the live CD.
- Determine the partition number of your main partition. GParted can help you here. I’m going to assume in this answer that it’s
/dev/sda2, but make sure you use the correct partition number for your system!
- Mount your partition:
sudo mount /dev/sda2 /mnt # make sure that sda2 is correct!
- Bind mount some other necessary stuff:
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
chrootinto your Ubuntu install:
sudo chroot /mnt
- At this point, you’re in your install, not the live CD, and running as root. Update grub:
If you get errors, go to step 7. (Otherwise, it is optional.)
- Depending on your situation, you might have to reinstall grub:
grub-install /dev/sda update-grub # I'm not sure if this is necessary, but it doesn't hurt.
- If everything worked without errors, then you’re all set:
exit sudo reboot
- At this point, you should be able to boot normally.
If you cannot boot normally, and didn’t do step 7 because there were no error messages, try again with step 7.
- Sometimes giving GRUB2 the correct configuration for your partitions is not enough, and you must actually install it (or reinstall it) to the Master Boot Record, which step 7 does. Experience helping users in chat has shown that step 7 is sometimes necessary even when no error messages are shown.
This final method involves more
First of all, you must start your system from a live cd. Then
“METHOD 3 – CHROOT
This method of installation uses the chroot command to gain access to the broken system’s files. Once the chroot command is issued, the LiveCD treats the broken system’s / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.
1) Boot to the LiveCD Desktop (Ubuntu 9.10 or later). Please note that the Live CD must be the same as the system you are fixing – either 32-bit or 64-bit (if not then the chroot will fail).
2) Open a terminal (Applications > Accessories > Terminal).
3) Determine your normal system partition – (the switch is a lowercase “L”)
sudo fdisk -l
If you aren’t sure, run
Look for the correct disk size and ext3 or ext4 format.
4) Mount your normal system partition:
Substitute the correct partition: sda1, sdb5, etc.
Example: sudo mount /dev/sda1 /mnt
5) Only if you have a separate boot partition: sdYY is the /boot partition designation (for example sdb3)
sudo mount /dev/sdYY /mnt/boot
6) Mount the critical virtual filesystems:
sudo mount --bind /dev /mnt/dev sudo mount --bind /dev/pts /mnt/dev/pts sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys
7) Chroot into your normal system device:
sudo chroot /mnt
8) If there is no /boot/grub/grub.cfg or it’s not correct, create one using
9) Reinstall GRUB 2:
Substitute the correct device – sda, sdb, etc. Do not specify a partition number.
10) Verify the install (use the correct device, for example sda. Do not specify a partition):
sudo grub-install --recheck /dev/sdX
11) Exit chroot: CTRL-D on keyboard
12) Unmount virtual filesystems:
sudo umount /mnt/dev/pts sudo umount /mnt/dev sudo umount /mnt/proc sudo umount /mnt/sys
13) If you mounted a separate /boot partition:
sudo umount /mnt/boot
14) Unmount the LiveCD’s /usr directory:
sudo umount /mnt/usr
15) Unmount last device:
sudo umount /mnt
#Special thanks to the users who posted these I just wanted