Restore Grub boot loader after installing Windows

I got some free time, after finishing my work (I do get a lot of free time these days don’t I?) Anyway when I was writing my previous post about Removing older kernels from Ubuntu Karmic I thought of writing a bit more about the grub so today I’m gonna write about how to restore grub.
When we install windows xp, vista, 7 or some other version of MS OS’s, while having ubuntu or some other Linux distribution we can see that, the grub menu goes away or simply put, the grub menu doesn’t come when the OS is booting. How can we go to ubuntu? Do we have to install ubuntu? (I’m using ubuntu here because I’m using ubuntu as my primary OS) those are the questions which come to mind to mind. But there is no point in being worried, we can restore the grub, and it will solve the problem 😀

Note: when it comes to grub 2 the process is a bit different (I’ll explain it later on)

Ok then lets start with Grub 1 (I call this grub 1 because the new one is called grub 2)

First insert the live CD and reboot. When the menu appears go to Try Ubuntu without installing menu and press enter.
When you get to the desktop open a terminal and type
sudo grub

This will lead you to a grub prompt which will look like this : “grub>”
Then from there you have to find where the grub is situated, to do that you can use the command,
find /boot/grub/stage1

and that will return something like hd0, 1 (It may differ) for the demonstration purpose I’ll use hd?. ?
now we have to enter
root (hd?,?)

for example if you got hd0,1 you have to type root (hd0,1)
Then you have to enter setup command which will install the grub to the MBR

and finally

And that will do the trick for grub 1 🙂

Now lets restore grub 2. When restoring grub 2 you have to have ubuntu 9.10 (for now or later version)
This part is a bit tricky and have a bit more to remember (keep that in mind)
As we did in the earlier process first you have to boot up ubuntu using the live CD then open a terminal and type,
sudo -i

This will make you the super user (root). If you think logging in as root is risky then don’t. What you have to change in the following commands is, you have to add “sudo” in front of each command 🙂
Now you have to identify the mounted partitions of your computer, to do that you have to enter the following command,
fdisk -l (usually you have to do sudo fdisk -l but as you are logged in as root you don’t have to)

Then from that result you have to find out in which partition ubuntu is installed. (it could be /dev/sda1 , /dev/sda2 etc.)

If you have partitioned your HDD as root(/), home, boot etc. separately then you have to select the partition which is used as boot if not, that means you if you have just root(/) and home then select the partition which is used as root. For now I’ll take /dev/sda1 as my root partition.

Now you have to mount that partition,
mount /dev/sda1 /mnt (we are working as root)

After mounting the root partition you have to bind the /dev and /proc you can do this by entering the following,
mount –bind /dev /mnt/dev
mount –bind /proc /mnt/proc
grub-install /dev/sda
grub-install –recheck /dev/sda

Important: Check the above command carefully it says /dev/sda and not /dev/sda1. “sda” means the full hard disk where ubuntu is installed

Now you have to unmount the partitions you mounted during the process,
umount /mnt/dev
umount /mnt/proc
umount /mnt

and then you have to reboot the computer.

And that does it 😀
I hope now you don’t have that to worry about 😀
Have fun,
Bye for now!!

~~ Rusiru Boteju ~~


About Rusiru Boteju
A peculiar or otherwise odd person, especially one who is perceived to be overly obsessed with one or more things including those of intellectuality, computers, technology, etc.

4 Responses to Restore Grub boot loader after installing Windows

  1. Nice article!!!

    I was writing the same one in sinhala. I will publish later 🙂

    In the method I found in the net, after mounting all the necessary partitions (/, /boot, /dev), a chroot command is given with the path as /mnt. This way the commands after that will act as root user and taking /mnt/ as the root (no sudo is needed). If chrooted, the grub-install command changes to just “grub-install /dev/sda” as the device will be in the chrooted ennvironment.

  2. Pingback: Tweets that mention Restore Grub boot loader after installing Windows « Life and Tech --

  3. Rich says:

    This worked FLAWLESSLY!!

    Thanks a ton!!


    P.S. Website is in support of my wife who is participating in the 3-day Komen Breast Cancer Walk!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: