Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

* * * * * 1 votes

How to re-install Grub bootloader after Windows re-install on a dual-boot system

  • Please log in to reply
3 replies to this topic

#1 Romeo29


    Learning To Bleep

  • Members
  • 3,194 posts
  • Gender:Not Telling
  • Location:
  • Local time:12:47 AM

Posted 26 July 2009 - 07:46 PM

How to add Grub bootloader after Windows re-install on a dual-boot system

Guide Overview :
You have a dual boot system with Windows and Linux both on separate partitions. You decide to format the Windows partition and re-install Windows after a malware attack or just because Windows got too much cluttered. The Windows setup re-writes the MBR of primary partition so after re-installing Windows, you no longer have Grub loader and you can no longer boot into Linux. This guide tells you how to re-install Grub bootloader after reinstalling Windows on a dual boot system.

Requirements :
A bootable Linux live CD. For example, a Ubuntu CD. http://www.ubuntu.com/GetUbuntu/download

Instructions :

  • Boot from the Live Linux CD.
  • Choose an option that says something like "Try Linux without installing".
  • After Linux desktop environment (like Gnome or KDE) is finished loading, open a Terminal window.
    Under Gnome, open Terminal through, Applications menu -> Accessories -> Terminal.
    Under KDE, open Terminal through, KMenu -> System -> Terminal Program (Konsole).

EDIT by Al1000: Please note that the remainder of this post does not apply to current Linux builds. Please see post #4 for up-to-date information

  • In the terminal, type sudo grub.
  • Next type, find /boot/grub/stage1 and press Enter. The output may look like hd0, 6
  • Type root (hd0, 6). Note that we have to use whatever output we get from previous command. If you get hd0, 2, then type root (hd0, 2)
  • Type setup (hd0) (again replace hd0 with the output of the find command) and press Enter. next type quit and press Enter to exit grub.
  • Thats it, Grub bootloader is loaded again in MBR. Restart your computer.

Edited by Al1000, 02 April 2015 - 08:21 AM.
Added parenthetical, just to be safe :) - AA

BC AdBot (Login to Remove)


#2 kokopeli


  • Members
  • 4 posts
  • Gender:Male
  • Location:Rochester, NY, USA
  • Local time:01:47 AM

Posted 28 October 2010 - 01:31 PM

Thanks a lot.
How many times I have reinstalled Ubuntu just to fix up GRUB after a Windoz install.
I hope this works with multiple hard drives - I don't see why not.
I made a copy of the procedure and put it on my server - I will certainly use it often.


#3 viperex


  • Members
  • 1 posts
  • Local time:10:47 PM

Posted 25 March 2013 - 10:10 PM

Do these instructions still apply to current Linux builds?

#4 Al1000


  • Global Moderator
  • 8,120 posts
  • Gender:Male
  • Location:Scotland
  • Local time:05:47 AM

Posted 31 March 2015 - 07:47 AM

That information is obsolete. Here are some up-to-date instructions:

Follow the initial steps 1 - 3 in the OP to boot from a live CD/DVD/USB, and open a terminal. Then:

To help find the name of the partition that Linux is installed on, in the terminal type:

sudo fdisk -l

The output might look something like this: (note this is not the real output on my computer; but rather a simplified version for the purpose of this tutorial)

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000026c7

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1230847 614400 b W95 FAT32
/dev/sda2 1232896 9621503 4194304 83 Linux
/dev/sda3 9623552 12769279 1572864 82 Linux swap / Solaris

We take two things from this output.

1) The name of the device is /dev/sda

2) The partition that Linux is installed on is /dev/sda2

If you are not entirely sure which partition your installation of Linux is installed on, please ask for advice in the Linux forum before proceeding.

Now mount the partition that your Linux installation is installed on, by running the following command in the terminal. Replace /dev/sda2 with the name of the partition your Linux installation is installed on, if it's not /dev/sda2

sudo mount /dev/sda2 /mnt

To install Grub to the MBR of your device, now run the following command. Replace /dev/sda with the name of your device, if it's not /dev/sda

sudo grub-install --boot-directory=/mnt/boot /dev/sda

That's it. Now reboot your computer, removing the live CD/DVD (and resetting the BIOS boot order if required), and you should have your Grub2 boot menu back.

Edited by Al1000, 02 April 2015 - 08:24 AM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users