How to restore Grub boot loader after installing Windows

Sponsored Link
This tutorial will explain how to restore Grub after installing Windows 7/Vista/Xp.If you are using dual boot PC with windows,Ubuntu for some reason you reinstall your windows now you may not see your grub 2 is loading because your windows installation might have been over written MBR (Master boot record).
Method 1

Using Ubuntu 9.10 livecd

First you need to download Ubuntu from Ubuntu site

In this tutorial we are assuming the Ubuntu partition is sdc3,and /boot partition is sdc2

Note:- You need to replace sdc3,sdc2 with your partitions.You can check your partition table with fdisk -l

Now Boot up ubuntu from the livecd,open terminal from Applications menu -> Accessories -> Terminal and login as root using the following command

sudo -i

mount /dev/sdc3 /mnt

mount /dev/sdc2 /mnt/boot

grub-install --root-directory=/mnt/ /dev/sdc

If you are not having “grub.cfg” file,use following contents to recreate

mount --bind /proc /mnt/proc

mount --bind /dev /mnt/dev

mount --bind /sys /mnt/sys

chroot /mnt update-grub

umount /mnt/sys

umount /mnt/dev

umount /mnt/proc


Method 2

Using GRUB for DOS

GRUB4DOS is an universal boot loader based on GNU GRUB. It can boot off DOS/LINUX, or via Windows boot manager/syslinux/lilo, or from MBR/CD. It also has builtin BIOS disk emulation, ATAPI CDROM driver, etc.

Download GRUB for DOS from here

For XP Users

copy the file grldr from grub4dos package to C:\.Edit boot.ini (hidden file) and add this line to the file:


For Windows7/Vista Users

Copy the file grldr,grldr.mbr to C:\.Create boot.ini file in the root directory of C:,copy and paste following into this file.

[boot loader]
[operating systems]

Now,create menu.lst in root directory,with the following content

timeout 0
default 0
title grub2
find --set-root /boot/grub/core.img
kernel /boot/grub/core.img

Now restart your computer,and select boot from Grub4Dos.Then select boot up Ubuntu in grub menu.
Once login,use this command to install grub into mbr

sudo grub-install /dev/sdc

Note :- Replace sdc with your partiton

Sponsored Link

You may also like...

11 Responses

  1. frank says:

    i found it easiest to first save the mbr to a file on a memory stick, and then recover it after booting from a live cd.
    google “save restore mbr +dd” – the instructions by Randy Cooper worked just sterling for me.
    just remember not to destroy your disk… =)

  2. Christian says:

    I think this should also work for migrating from LILO to Grub if you installed Ubuntu from the Alternate CD.

  3. Fikret says:

    Here is a simple way

    Only five command

    sudo grub
    find /boot/grub/stage1
    root (hd0,5)
    setup (hd0)

  4. Christian says:


    Ääääääh, ja. Ich mag zwar n Berlin-Kreuzberg wohnen, aber ganz so einsichtlich war das für mich nicht.

    Wird aber schon stimmen. Danke 😉

  5. Christian says:

    Ehm, sorry. Too early with a coffee mug in my hands. Been reading in English and writing in German 😉

    Grab the translation here:

  6. Ole says:

    Ha ha. Your way is for grub1. This for grub2.

  7. Red R says:

    Hi, My Distro is Fedora 11 dual with Windows XP but I’m sure Ubuntu Grub is just the same. I could be mistaken but it seems to me you are all really going about this the hard way; me I’m just lazy, go here: download the Supergrub boot disk of your choice (CD,USB Flash or Floppy) boot your system with it read what it says and press number 1 (usually) on the menu and that should fire up your usual session and when you close down and restart the Grub boot menu should be back to where it was before Windows trashed it :o)

  8. crash says:

    Thanks for these instructions, but they aren’t working for me. When I enter

    grub-install –root-directory=/mnt/ /dev/sda

    It tells me:

    mkdir: cannot create directory ‘mnt//boot’: No such file or directory

    If I try the directions listed right underneath, when I type

    choot /mnt update-grub

    I get:

    No GRUB directory (and some other stuff about creating a template…)

    Any ideas?

    (I also tried the instructions for installing grub in Windows, but I don’t know how to create a boot.ini file.

  9. Bart says:


    /dev/sda — dude, you missing a partition number!

  10. dave says:

    alright so i burned a cd of 10.04 trying to do all these things, but when i run the cd, i choose “try for free without installing” or whatever it says. because if i do not, i would have to copy over the ubuntu that is already there right? so i am on the right place yea? cause nothing is working for me.. i get this..

    Disk /dev/sda: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xaed0254e

    Device Boot Start End Blocks Id System
    /dev/sda1 1 1306 10485760 27 Unknown
    Partition 1 does not end on cylinder boundary.
    /dev/sda2 * 1306 10380 72885248 7 HPFS/NTFS
    Partition 2 does not end on cylinder boundary.
    /dev/sda3 10380 10771 3145796 7 HPFS/NTFS
    /dev/sda4 10772 19457 69770295 5 Extended
    /dev/sda5 19098 19457 2891668+ 82 Linux swap / Solaris

    Disk /dev/sdb: 8210 MB, 8210350080 bytes
    74 heads, 10 sectors/track, 21670 cylinders
    Units = cylinders of 740 * 512 = 378880 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x04030201

    Device Boot Start End Blocks Id System
    /dev/sdb1 8 21671 8015136 c W95 FAT32 (LBA)

    please tell me wtf im sposed to do

  11. Meow says:

    Using “dd” to back up your hard drive’s bootloader seems to be a simplest way to fix your grub menu after a new installation for windows. while installing windows is done, boot your pc with a linux live usb key, then use “dd” to restore the file aka the bootloader you backed up previously in terminal, after reboot your pc the menu will show up again.

Leave a Reply

Your email address will not be published. Required fields are marked *