Most of the desktop users are comfortable with Windows, and when they want to try Linux, they dual boot their systems. When you need to dual boot your system, and it already has windows installed, Linux can be installed alongside Windows with no problems. The Linux bootloader supports Windows and allows you to choose from a number of choices of Operating systems, i.e. while booting, you can chose whether you want to boot windows or Linux. But if you need to install/reinstall Windows on a system with Linux (dual boot), Windows wipes the GRUB bootloader's files from MBR and you are no longer given a choice between Windows and Linux.
This article describes how you can get back your GRUB without need to reinstall Linux all the way.
Recovering back GRUB bootloader
Boot from your bootable Ubuntu CD/DVD or bootable USB drive.
Select option "Try Ubuntu without installing" when asked between trying and installing Ubuntu.
Mount your root partition manually or from nautilus/from places.
If you have mounted it manually (from command), then you know the mount point. But if you have mounted it using GUI, then we need to find the mount point. Run the 'mount' command to get the mount point of root partition:
aufs on / type aufs (rw)
none on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
/dev/sr0 on /cdrom type iso9660 (ro,noatime)
/dev/loop0 on /rofs type squashfs (ro,noatime)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/ubuntu/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ubuntu)
/dev/sda1 on /media/5502cc26-c158-46f8-b222-a20a207a5cef type ext4 (rw,nosuid,nodev,uhelper=udisks)
We are interested in the last line in the output of this command. It says something like "/dev/sdax on /media/550....". The mount point is the path written after "on", i.e. '/media/5502cc26-c158-46f8-b222-a20a207a5cef' Copy this path. We will need this in subsequent command.
Now we will install GRUB on the MBR of the hard drive.
Here I assume that your hard disk is /dev/sda. If you have more than one hard drive, then you must provide the correct hard drive. But if your system has only one hard drive, it will most probably be /dev/sda. You can check it from the output of mount command.
The --root-directory option must be set to the mount point of root directory that we found in the above step.
$ sudo grub-install --root-directory=/media/5502cc26-c158-46f8-b222-a20a207a5cef /dev/sda
Installation finished. No error reported.
That’s it. The GRUB has been recovered on the MBR. Now you can again chose from the list of Operating systems.
Here is a bonus piece of information: You can boot from some other distribution or version than the installed Linux for this process, i.e. for example if you have Ubuntu 12.04 installed on the system, then you can use CD/DVD/bootable image of Linux Mint or Ubuntu 10.04 or some other distribution/version. These steps will work fine with almost all distributions.
You might also like
Filed Under : UBUNTU HOWTO