My thoughts on Tech

[How To] Fix MBR after installing/uninstalling Windows/Linux in a dual boot

Many, who do a dual boot with any Linux and Windows will face the problem of Master Boot Record (MBR). In easier words, one of them (Windows or Linux) wont boot after installing/uninstalling the other. This is a small guide I hope many would find it useful.

FIXING WINDOWS BOOT AFTER UNINSTALLING LINUX

For Windows XP: Boot the installation CD and select repair. Enter your windows installation drive number (shown there) and enter Administrative Password. Now run these two commands there one after the other  — “fixmbr” and “fixboot”. Optionally some people also run “bootcfg /rebuild”. You’re Done.

For Windows Vista: Boot from the installation CD/DVD and enter “Repair Windows” link at the left hand bottom of the dialog. Then go to command prompt . There run “bootrec /fixmbr” and “bootrec /fixboot” commands one after the other. That does it.

FIXING GRUB AFTER INSTALLING WINDOWS

1.Boot from a LiveCD and open the terminal..

2.There enter sudo grub to enter GRUB prompt.

3.Type find /boot/grub/stage1 to find out your Linux partition.

4.Then use the device name that was output in the next command, say (hd0,1). Then the command would be root (hd0,1).

5. After this, say setup (hd0). Replace hd0 with your hard drive.

Now your GRUB should be installed fine. However, your windows’ boot entry may not be in GRUB. You may choose to restore it while still being in your LiveCD or after booting into your hard-drive installed Linux.

To restore it:

1. Open /boot/grub/menu.lst of your Linux partition, in a text editor and get to the bottom where all the list of options to boot are found.

2. Add the following lines with your Windows name in the title and replace (hd0,0) with your own hard drive and partition:

title   Windows 95/98/NT/2000
root   (hd0,0)
makeactive
chainloader+1

3. Save and reboot.

EDIT:

ADDING WINDOWS XP (AND OLDER) OPTIONS TO VISTA’S BOOT LOADER

After installing Windows XP after Windows Vista and after restoring Vista’s bootloader one may find that xp or older windows’ options will not be there. For this please make use of a software called EasyBCD. The installation and operation are self-explainatory. Just click on Add/Remove Entries and add your OS entry. You may also add your linux and mac entries to it. Also there is an option for having a common bootloader using NeoGrub.

If you enjoyed this post, make sure you subscribe to my RSS feed!

9 Comments

  1. October 29, 2008    

    Hey Sathya,

    Nice post. Learnt the Unix side of the equation.

    For restoring Windows MBR, I generally dont use fixmbr as I havent yet found it on any of the OEM CD’s that I’ve used ;-).

    Instead, I use a tool called MBRFIX. However, there is a catch, you must be able to boot into the windows partition. And this guy is pretty brute-force in the way it works… :)

    Check it out here: http://www.sysint.no/Download/tabid/162/language/en-US/Default.aspx

  2. October 29, 2008    

    Hey Cruise! Bharath’s the author of this post, so credits to him. The catch seems more like Catch-22 as if you are likely to Fix MBR, then your Windows partition isn’t booting, and to use this utility, your Windows must be booting ;-)
    Thanks for the comment!

  3. December 16, 2008    

    Hey By “Your linux partition”Do you mean that I should mount my linux partition (say hda3) and then go to the mounted locations /boot etcetc?

    • December 16, 2008    

      Existing Linux partition should get mounted automatically

  4. Bharath Ram's Gravatar Bharath Ram
    December 18, 2008    

    @ Reeteshinator

    Your linux partition = the partition where u installed ur linux and wanna restore it

    and s u shud mount it else how else can u access /boot/etcetc ????

  5. December 23, 2008    

    Hmm.. ok, it seems the second step is not required itself.. installing the Grub automatically detects all other installations and adds them.

    i.e a simple grub re-install and restart is more than enough to get the windows things in the list too :D

    • Bharath Ram's Gravatar Bharath Ram
      December 25, 2008    

      I think the second step is required……….
      GRUB install doesnt identify and add other installations…….
      it may detect during linux install but not this way………..

    • December 25, 2008    

      Don’t know, it depends I guess. Grub has always detected my Windows and existing Linux partitions so I never had to do the second step.

  6. manish's Gravatar manish
    October 23, 2009    

    hey awesome trick to repair mbr,also i have a problem i am not able to use my inbuilt bluetooth device in linux becoz i donn’t know how to activate it.i have installed gnome* package it shows bluetooth icon bt by clicking there is nothing response…also how to connect internet using bluetooth in linux help me

1 Trackback

  1. Linux Switchover Guide on December 20, 2008 at 11:26 am
  2. Blue screen when booting up - partition issue? on January 16, 2012 at 2:09 am
  3. unostar on May 2, 2012 at 1:13 pm
  4. Please urgent rply needed, booting error on February 8, 2013 at 9:32 am

Leave a Reply

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

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