Recovering Ubuntu after Windows Installation

Many of you are having a dualboot PC having both Ubuntu and Windows installed. But sometimes you may need to reinstall windows due to the performance loss or system crash or due to the non-recoverable virus attacks. After you have installed the new Windows the Microsoft bootloader just overwrite MBR and the GRUB & dualboot entries are gone. You didn’t have an entry to your favourite Ubuntu system. Here is a simple trick to recover your lost Ubuntu by reinstalling GRUB to the MBR by using the Ubuntu live CD

  1. Insert the Live CD and boot from it
  2. After ubuntu is loaded, open a terminal
  3. Now, type
    sudo grub-install /dev/sda
  4. Done. The GRUB will be installed to the MBR
  5. Reboot the PC

Another Method to  install GRUB if the above didn’t work

This option will use the Desktop/Live CD to install Grub into your MBR (Master Boot Record). This option will overwrite your Windows Boot Loader It is OK to do this, in fact that is the goal of this how to (in order to boot Ubuntu)

1. Boot the Desktop/Live CD.

2. Open a terminal (Applications -> Accessories -> Terminal)

3. Start grub as root with the following command :

sudo grub

4. You will get a grub prompt (see below) which we will use to find the root partition and install grub to the MBR (hd0,0)

   [ Minimal BASH-like line editing is supported.   For
         the   first   word,  TAB  lists  possible  command
         completions.  Anywhere else TAB lists the possible
         completions of a device/filename. ]

grub>

Type the following and press enter:

find /boot/grub/stage1

Using this information, set the root device:

grub> root (hd0,1)

Install Grub:

grub> setup (hd0)

Exit Grub:

grub> quit

5. Reboot (to hard drive). Grub should be installed and both Ubuntu and Windows should have been automatically detected.

6. If, after installing grub, Windows will not boot you may need to edit /boot/grub/menu.lst (That is a small “L” and not the number 1 in menu.lst)
Open a terminal and enter :

 gksu gedit /boot/grub/menu.lst

Or, in Kubuntu:

kdesu kate /boot/grub/menu.lst

Your Windows stanza should look something like this :

 title Windows XP/Vista # You can use any title you wish, this will appear on your grub boot menu
 rootnoverify (hd0,0) #(hd0,0) will be most common, you may need to adjust accordingly
 makeactive
 chainloader +1
Advertisements

1 Comment

Filed under Linux, Tips, Ubuntu

One response to “Recovering Ubuntu after Windows Installation

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s