Tuesday, September 15, 2009

Recover Ubuntu Grub loader after installing Windows

Recover Ubuntu Grub loader after installing Windows

If you run a dual-boot system with linux and Windows, this has happened to you. You had to do your monthly reinstall of Windows, and now you don’t see the linux bootloader anymore, so you can’t boot into Ubuntu or whatever flavor of linux you prefer. You can easily recover GruB loader .
To do:


  • To recover Grub loader after installing windows you'll need a Live-Cd of the Linux (same flavor of installed linux) and Root access.
  • Boot form live CD
  • Open terminal and type the following code.
          sudo grub
          > root (hd0,0)
          > setup (hd0)
          > exit
    note that hd0,0 implies the first hard drive and the first partition on that drive, which is where you probably installed grub to during installation. If not, then adjust accordingly.
  • Now reboot your computer
Trouble Shooting:


If Windows is now missing from the boot menu:   
If you installed Ubuntu before you installed Windows, then Ubuntu will not have anything in the grub configuration for Windows. This is where you’ll have to do a bit of manual editing to the grub boot menu file.

Open the file /boot/grub/menu.lst with the following command:
sudo nano /boot/grub/menu.lst
Here nano is text editor which i use. you can change this to default text editor for linux gedit if you dont have nano

This is a sample codes for  windows in grub loader:
Paste this code into menu.lst file and click save.
title Windows 95/98/NT/2000/XP/XP Pro/Vista
root (hd0,0)
makeactive
chainloader +1

Note that you should also verify that hd0,0 is the correct location for Windows. If you had installed Windows on the 3rd partition on the drive, then you should change it to (hd0,2)


:)

No comments:

Post a Comment