Subscribe to Hacking Truths. Now, 19968 members!      RSS Feed Be Our Fan on Facebook Twitter SMS Alerts

Home » Cool Tricks, Hacking Tutorials, Linux Hacking, Tips n Tricks

Recover Ubuntu Grub loader after installing Windows

18 March 2009 7 Comments Posted By
StumbleUpon.com
Share

ubuntuIf 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.

Here’s the quick and easy way to re-enable Grub.

1) Boot off the Live CD

2) Open a Terminal and type in the following commands, noting that the first command will put you into the grub “prompt”, and the next 3 commands will be executed there. Also 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.

sudo grub

> root (hd0,0)

> setup (hd0)

> exit

Reboot (removing the live cd), and your boot menu should be back.

Only read below 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.

If you open the file /boot/grub/menu.lst with the following command:

sudo gedit /boot/grub/menu.lst

You’ll see a sample section for Windows, which you’ll want to uncomment and add to the boot menu list in whatever position you want it in. (uncomment by removing the #’s)

# title   Windows 95/98/NT/2000/XP/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 4th partition on the drive, then you should change it to (hd0,3)

Popularity: 3% [?]

You might be interested in the following Articles

  1. How to safely uninstall Linux when Dual boot installed with Windows XP?
  2. Keyboard Shortcuts for Ubuntu
  3. Hungry Hacker’s Toolkit
  4. HowTo: Reinstall Ubuntu Automatically
  5. How to Install any Linux on a USB
  6. 10 ways to Tweak your Linux Boot Process
  7. Booting Windows XP with USB Flash Drive
  8. How to Recover Important Data after your System is Crashed


Enjoyed this article? Subscribe to Hacking Truths and get daily updates about new cool websites and programs in your email for free.


7 Comments »

  • Rich said:

    thanks a million!! helped a noob in serious trouble

  • Samuel said:

    Thanks a ton! I’ve been looking for this for a long time. Thanks again!

  • Peter Lutz said:

    Now how do we do this with GRUB 2?
    Thanks.

  • Sarika said:

    Hi
    I could not recover my Ubuntu 10.04, because when I type “sudo grub”, it gives o/p as “command not found”. Please help me to overcome this problem. I am inserting live CD.

  • amit said:

    I have a dell xps laptop. which has got vista .
    After working on dual boot for a long time I had to format vista.
    Now I dont see the grub menu which used show up at system boot, earlier.
    By default system boots into vista now. No traces of earlier boot menu.But the Ubuntu Partitions r still there.
    Can anyone help me in the issue.
    I would need the system to dual boot just it like earlier.

    Thanks

  • affiliatesea said:

    Thanks a lot. I was looking for this solution from long time.My windows crashed and i am using only ubuntu from long time.I will try to install windows again and try dual boot.thanks for the tip again.

  • rodvek said:

    for grub 2:

    Using Ubuntu 9.10 livecd or higher
    Here assuming the Ubuntu partition is sda7,and /boot partition is sda6 (if you have a separate /boot partition).
    Boot up ubuntu from the livecd,open terminal and run:
    sudo -i
    mount /dev/sda7 /mnt
    mount /dev/sda6 /mnt/boot #skip this one if not have a separate /boot partition
    grub-install –root-directory=/mnt/ /dev/sda

    that’s all (ubuntu tunisia) :)

Note : If you have any Query related to the above Article please Post it to the Support Forum.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.