Dual-booting all versions of Windows and Linux

   Dual-Boot    |    Win 8    |    Win 7    |    Vista    |    Win XP/2K/NT    |    Win9x/Me    |    How to    |    Legacy 9x Tweaks    |    SiteMap   


Here: Home > How do I ... >

Restore, Repair or Create a Windows or Linux Boot Sector, MBR, Boot Loader

Last reviewed: May 2010

On this page:


Installation of an operating system (OS) creates a new Boot Sector and MBR (Master Boot Record) which is specific to that OS. This works with the boot file(s) to run a Boot Loader/Manager that loads the OS into memory. All of these must be correct for the expected OS or it will not boot.

This guide applies mainly to dual-booters who have overwritten the Boot Sector/MBR of one operating system (OS) with that of another operating system - now the required Boot Loader/Manager Menu cannot appear. This can occur while setting up a dual-boot. It can also occur when you reinstall the OS that does not control the Boot Loader menu. You can also use these procedures if you suspect the Boot Sector of a single OS installation has been damaged.

The instructions below will overwrite the existing Boot Sector/MBR with one for the OS of your choice and that OS will then be bootable - provided its boot files and OS files/folders are intact. You should select the option that fits your own situation. For example, if you overwrote with Linux's GRUB and you want Windows 7 boot control back then select "Restore the Windows 7 or Vista Boot Sector".

Please note that these solutions will not fix a problem the OS itself or with its boot files.

This guide is suitable for advanced computer users only.

Restore a Windows 7 or Vista Boot Sector

Your computer will boot to Windows 7 or Vista if you execute the following procedure.

  1. Bootup from any Windows 7/Vista installation DVD or even from NeoSmart's free Windows 7 System Recovery Disk or Vista Recovery Disk.
    • Press a key when you see Press any key to boot from a CD or DVD.
    • Select your Language and then Time....
    • Select Repair your computer (bottom left of the Install now screen).
      An automatic check of your system will run but will not identify GRUB control!
    • In System Recovery Options, highlight Windows 7, and click Next.
    • Click Command Prompt in System Recovery Options.
      • Type in, and press ENTER after each line (not case sensitive)
        (the Win7/Vista's boot sector/loader will be reinstalled).
    • Now click Startup Repair in System Recovery Options.
    • Restart computer.
      Windows should boot as originally.

[top of page]

Restore a Windows XP or 2000 Boot Sector

  1. Make sure you can boot from a bootable CD.
  2. Boot from the XP/2K installation CD or from Setup Boot disk 1.
    The "Welcome to Setup" screen appears.
        (some XP Recovery CD's don't start SETUP - use XP Setup Boot Disks).
  3. For XP: Press R to "Repair a Windows XP installation using Recovery Console".
    For 2K: Press R to "Repair a Windows 2000 installation",
        and then press C to enter the Recovery Console.
  4. Type - and then press [Enter]
  5. Restart computer.

[top of page]

Restore a Windows 9x/Me Boot Sector

  1. You must have a Startup Disk, or bootable CD, made by the same version of Win9x/Me.
  2. Bootup from the Win9x/Me boot disk.
    • At the A:\> prompt, type - and the press [Enter]
      SYS C:
      (you will see a System transferred message).
  3. Remove floppy, and reboot.
    Win9x/Me will boot normally without any Boot Menu.

[top of page]

Restore Linux's Boot Sector with GRUB2

GRUB2 replaced the legacy GRUB in Linux Ubuntu 9.10 and later. It now comes with most of the later versions of the other Linux distros that used GRUB. Ubuntu 10.04 was used in testing the procedure to reinstall a Boot Sector that uses GRUB2.

It will be assumed that GRUB2 was previously installed to the MBR (hd0) of the first hard disk.

  1. Run Linux from your Ubuntu 9.10(+) Live CD, and open a Terminal window (it's like a DOS window)
    Terminal is usually in Applications/Accessories.
    Remember to use only lower case in the following - Linux is case-sensitive).
  2. First identify your disk and partitions. Type (the l in -l is the letter L in lower case)
    sudo fdisk -l
    From the output, identify the disk name in top line of output, like /dev/sda or /dev/hda
    and the partition name of your Linux, like /dev/sda3 or /dev/hda3
    Make sure you use that name instead of /sda? in the next three lines. Type
    sudo mkdir /media/sda?
    sudo mount /dev/sda? /media/sda?
    Now, to install GRUB2 in the correct location, type
    sudo grub-install --root-directory=/media/sda? /dev/sda
    (where sda? is your Linux drive, and sda is your hard disk, as shown in the fdisk output).
  3. Type exit to exit the Terminal and restart your computer.
    As you reboot, you will have the GRUB2 boot loader menu at startup.

[top of page]

Restore Linux's Boot Sector with GRUB

It will be assumed that GRUB was installed to the MBR (hd0) of the first hard disk. Ubuntu 9.04 was used in testing.

  1. Run Linux from your Ubuntu Live CD, and open a Terminal window (it's like a DOS window)
    (Terminal is usually in Applications/Accessories).
  2. First get to a GRUB prompt. Type:
    sudo grub
  3. GRUB extends beyond the very small MBR and has different Stages.
    Find and note the location of GRUB's Stage 1. Type:
    find /boot/grub/stage1
    You will be shown the location of Stage1, like (hd0,4)
    (if more than one Stage1 is located, you must choose which one to use).
  4. Replace the following hd?,? with the location just found. Type:
    root (hd?,?)
  5. hd0 is the GRUB label for the first drive's MBR (that 0 is a zero). Type:
    setup (hd0)
  6. Type:
  7. Open Partition Editor and right-click the partition where GRUB is setup - usually (hd0).
    Select Manage Flags and make sure the Boot flag is ticked for this partition.
  8. Exit GParted, and Restart. Remove the CD when it pops out.

When you reboot, you will have the GRUB boot loader menu at startup.

It's not essential for GRUB to be written to the MBR on the first hard disk (hd0). If you want GRUB on a Primary partition, the setup (hd0) step can be altered to setup (hdX,Y). The X part is the hard disk number (0=first disk, 1=second). The Y part is the Primary partition number (0=first partition, 1=second, etc). This method will leave the MBR on (hd0) unchanged.

Remember that GRUB starts counting at 0
(a 0 is the first, 1 is second, ...). That means, for example:
/dev/hda1 in Linux equates to (hd0,0) in GRUB (hd0 = first hard disk and ,0 = first partition)
/dev/hda2 in Linux equates to (hd0,1) in GRUB (hd0 = first hard disk and ,1 = second partition)
/dev/hda3 in Linux equates to (hd0,2) in GRUB (hd0 = first hard disk and ,2 = third partition)
/dev/hdb1 in Linux equates to (hd1,0) in GRUB (hd1 = second hard disk and ,0 = first partition)

[top of page]

Please remember that you alone are responsible for the consequences of any changes you make to your computer hardware or software.

Copyright © LarryM 1998-2015