Dual boot Windows 7/8 and Linux/UNIX

(UNIX BSD descendants like FreeBSD, MAC OS X and Linux descendants like Ubuntu, Fedora)


This guide assumes you have an installed and running Windows 7 or Windows 8 on a MBR style disk. Then you install a second non-Windows OS.

If you install Windows 7/8 as second OS there is no problem. Windows 7/8 boot manager will be in control of the booting after installation.

Every OS be it Windows or not takes at least one partition for installation. So you need at least two (or more) partitions for installing two OSs.

We assume installing to one disk and separate partitions. Unix BSD descendants need a primary partition. Linux descendants can be installed to logical partitions.


If you have two disks available for installation it is best to use completely separate installation of every OS to its own disk and dual-boot over one time boot device selection key in BIOS. (Separate installation method: You install one OS to its own disk and during installation only one disk is attached to the system). This way you don't need a boot sector loader and have a robust dual-booting over BIOS boot device selection!


1. Where to install the "foreign" boot loader

The best place for installing the (first stage of ) a loader for a non-Windows OS is the partition boot record (PBR) - first sector of partition chosen for OS installation.

Usually there is a choice during installation where to put the boot loader. DO NOT SELECT MBR or your normal Windows 7/8 booting will be gone!

You can always reinstall Linux/Unix loader to PBR - a single command like
"grub-install /dev/sda3"
in Ubuntu/Fedora installs GRUB2 boot sector to partition 3.


You do not have to reinstall Windows 7/8 if you can no longer boot to it (if you made a mistake and destroyed Windows MBR for example) - you can repair the booting of Windows 7/8 using Windows 7/8 installation/recovery media. See - How to repair Windows 7/8 booting.


2. Create Boot Sector Loader for dual booting UNIX/Linux based operating system (OS)

To dual boot an UNIX/Linux based operating system with Windows 7 boot manager a so called "boot sector loader" is needed.

This concept works only on computer systems with MBR disks and BIOS hardware.

Computer systems equipped with EFI and GPT disks use a different booting mechanism.

Windows 7/Vista boot manager (bootmgr) can boot any non-Windows OS using a boot sector loader.

The boot sequence in Windows 7 when using a boot sector loader is as follows:

  1. On power on the computer system executes the Power On Self Test (POST) in BIOS.
  2. Code from first disk first sector (MBR) is loaded and executed by BIOS.
  3. MBR code loads and executes code stored in first sector (PBR) of active partition.
  4. PBR code loads and executes boot manager (bootmgr) from "\" - root of active partition.
  5. Boot manager reads BCD ("\boot\BCD" on active partition) contents and displays boot menu.
  6. User selects "boot sector loader" entry from boot menu.
  7. Boot manager loads "boot sector file" specified in "boot sector loader" object and transfers control to it.

The code in "boot sector file" launches another OS specific boot sequence.


A boot sector loader object can be created using bcdedit.exe like this:

bcdedit will return an ID for this entry (for example something like - {de50478b-bb21-11e1-837e-001d72ceba3a}) that we will call {FreeBSD_ID} below. Do not use the example ID - bcdedit will create and return the ID you should use!

In this example the file 'C:\FreeBSD.pbr' is called "boot sector file".

This file is the core part of a boot sector loader. The file can be stored under any name and Windows folder.


Using Visual BCD Editor the same boot sector loader object is created by selecting "Create boot sector loader" in the pop-up menu.

Adjust ApplicationDevice(=C:) and ApplicationPath(=\FreeBSD.pbr) to point to boot sector file.

The Description element of the loader defines the text that will appear in boot menu for this loader.

A boot sector loader object has only three elements: ApplicationDevice, ApplicationPath and Description.

FreeBSD loader


Now we know how to create a boot sector loader using either bcdedit or Visual BCD.

Let's see how the boot sector file can be created.


3. Create Boot Sector File


The boot sector file should have the contents of the partition boot record (PBR) or MBR depending on installation method of the non-Windows operating system (OS). A valid (master or partition) boot sector/record is always 512 bytes long and its last two bytes are 0x55 0xAA (see image below). HxD Hex editor for example can display a boot sector file.

The easiest way of creating this file would be by using Boot Sector Viewer part of Visual BCD Editor (next version) or DualBootRepair tool for Windows 8 and later.


1. First select the partition where the UNIX/Linux OS is installed - this is shown as a "not mapped" (by Windows) partition in the partition list.

2. Check that this is the needed partition by looking at partition type and size.

3. Click on "Save" button, select a file name and folder where to save the file (e.g. c:\FreeBSD.pbr) and confirm.



Alternative 1:

A second method (and maybe the cleanest) is to use the "first stage" of boot loader from the OS itself.

Copy the file to a Windows folder.


A. For FreeBSD the file is "/boot/boot1"

The utility "ufs2tool - ufs for Windows" gives read access to a BSD partition.


The syntax for partition access is 0/3/0 =>disk 0, slice 3, partition 0 (a)


B. For Ubuntu, Fedora with GRUB2 the file is "/boot/grub/boot.img"

The tool "ext2fsd" gives read/write access to ext2/3/4 Linux partitions.

You run the tool and map Linux partition. After that you can use Windows Explorer for accessing ext2/3/4 partitions.

You can benefit from installing ext2fsd tool later for copying any Linux file to Windows and vice versa - great tool !


C. For older versions of Ubuntu, Fedora with Grub Legacy boot loader the file is "/boot/grub/stage1".

You can use the tool "ext2fsd" - see above.


D. For MAC OS X with Chameleon - the file is "/boot/[chameleon/]chain0".

(Installing MAC OS X to PC and MBR disk is not trivial ! It is not very clear if installation to PC is completely legal if you purchase OS X installation media ?)

You can use "HFSExplorer" - GUI tool which gives read access to HFS(+) partitions. See doc on site.

Needs Java Runtime Environment (v5.0 or later).


E. Other boot loaders: syslinux, lilo ...to follow.



Alternative 2:

Another method is to extract the partition boot sector with dd for Windows.

For partition 3 the command is:

dd count=1 if=\\?\Device\Harddisk0\Partition3 of=c:\FreeBSD.pbr



It takes some time and effort to code apps and maintain a website, and liters of coffee ;)