Restore Grub boot loader after installing Windows
April 15, 2010 4 Comments
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 :D
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
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,
and that will return something like hd0, 1 (It may differ) for the demonstration purpose I’ll use hd?. ?
now we have to enter
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 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,
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 –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,
and then you have to reboot the computer.
And that does it :D
I hope now you don’t have that to worry about :D
Bye for now!!
~~ Rusiru Boteju ~~