Recover Ubuntu after installing windows
Posted by cognoscis on 7th September 2009
So, you installed windows after installing Ubuntu and did not make a backup of the GRUB annd now you cannot boot into linux. Its not even listed in the options at the start up! Its not the end of the world. There is an easy way to get your GRUB back to normal.
Things you need :
One messed up compute
One Ubuntu live CD
Well, thats about it. Now, one major thing that you need to remember is that you need to have the same version of live CD as the one installed on your computer. Meaning, if you have Ubuntu 9.04 on your computer, then you need the same live disc. Thats because the lower version grub cannot open the higher version grub files. So, once you have this the procedure is very simple. Just boot from the live disc and wait till Ubuntu loads. Then, go to applications -> accesories -> Terminal
Now, once in the Terminal, type “sudo -i” without quotes and press enter. Once you do this, you will be in root and you need to be extra careful of what you type. Specially spelling errors and case of the letters (capitals and small letters).
Next, you need to determine what partition is Ubuntu installed in. To do this, in the terminal type “fdisk -l” (Its minus symbol followed by letter L in small case). After this, it gives the list of partitions as shown in the figure below. In that find your linux partition. Mine is sda5 as highlighted there.
I have only one here (excluding swap). You may have two or more depending on your configuration. So, now you need to mount these drives. To do this, create a mount point. To do this type,
mkdir /mt/ubuntu
Note that there is space between “mkdir” and “/mt/ubuntu”
You can name it anything really. Now mount the partitions at this point.
mount /dev/sda5 /mt/ubuntu
Note that there is space between “mount” and “/dev/sda5″ and “/mt/ubuntu”
That will mount your linux partion. IF you have a separate “/boot” partition, then you need to mount that too. Say, if the boot partition is in sda3 then
mount /dev/sda3 /mt/ubuntu/boot
Note that there is space between “mount” and “/dev/sda3″ and “/mt/ubuntu/root”
Now its time to reinstall the grub. To do this type
sudo grub-install –root-directory=/mt/ubuntu /dev/sda
Note that there is space between “grub-install” and “–root-directory=/mt/ubuntu” and “/dev/sda” . Once this is done you will get a message as below
“Installation finished. No error reported.
This is the contents of the device of the device map /boot/grub/device.map.
Check if this is correct or not. if any of the lines is incorrect,
fix it and re-run the script ‘grub-install’.
(hd0) /dev/sda”
Thats it. Done. Reboot the system and you will have your grub back. Now, you will have an option in the end that says windows which will take you to the windows OS choices (if you have more than one version of windows installed in your system). If you dont find windows in that list, boot to Ubuntu and open a Terminal and type
gksu gedit /boot/grub/menu.lst
This will open the menu list. There, when you scroll down, you will find the Ubuntu listed there. Below that there will be a line saying
### END DEBIAN AUTOMAGIC KERNELS LIST
# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root
Now, below this you add the following
title Microsoft Windows XP Professional (Or any other version)
root (hd0,0)
savedefault
makeactive
chainloader +1
That will get the windows back in the list. Please provide any additional details or suggestions through comments
Tags: dual boot, Recover GRUB after installing windows, Recover Ubuntu after installing windows, Recover Ubuntu after installing windows 7, triple boot, Ubuntu, windows 7, Windows XP
Posted in Issues I faced | No Comments »



