Simple dual-boot Windows and FreeBSD 9 under MBR

Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated.

Simple dual-boot Windows and FreeBSD 9 under MBR

Postby nsth » 15 Jan 2012, 00:42

Since [FILE]bsdinstall[/FILE] is geared towards GPT installations, it's not so easy to dual-boot a fresh install of FreeBSD with an existing install of Windows on the same drive. I'm assuming here that you have an existing installation of Windows under an MBR structure. If you're running 64-bit Windows 7 under a UEFI motherboard, there's a fair chance your drive is operating under GPT. You can check this with GParted (under drive information, partition style should read 'msdos' if it is MBR-structured).

This tutorial will result in a FreeBSD installation with a UFS root partition. This does not cover ZFS.

The bootselect code will be the minimalist [FILE]boot0[/FILE] code as installed by previous versions of FreeBSD. Sorry, fancy bootselect fans.

The following only applies under MBR!
Back up anything you don't want to lose!
This worked for me but it may not work for you!

Assuming you have Windows installed, start your already-prepared FreeBSD installer from CD or USB. Follow the prompts as per the Handbook's instructions for [FILE]bsdinstall[/FILE] until you come to the first partitioning prompt.

You are given the choice of Guided, Manual or Shell partition setup. Select Manual. You should see a hierarchy of your storage devices. From here I will assume that your installation target drive is [FILE]ada0[/FILE]. If it is [FILE]ad0[/FILE] or otherwise, be sure to substitute. You may want to note the name of the storage device for later on.

On [FILE]ada0[/FILE], you should see an NTFS or FAT partition, named [FILE]ada0s1[/FILE] or similar. Select the parent ([FILE]ada0[/FILE]) and Create and hit Enter to create your FreeBSD MBR partition. Change Type to "freebsd". Change size to the total intended size of all your FreeBSD slices, including Swap space. Don't enter a mountpoint. Select OK.

From here, make sure the first slice you create is your root slice, otherwise your install will not boot. [FILE]bsdinstall[/FILE] does not appear to modify the order of slices from how you enter them, so you have to make the root slice first to ensure your installation is bootable.

To do this, select [FILE]ada0s2[/FILE] (the partition you created before) and select create. Then enter
Code: Select all
Type: freebsd-ufs
Size: <desired size postfixed with MB or GB>
Mountpoint: /
Label: <whatever pleases you>

Note that for an MBR partition, you do not create a 'freebsd-boot' partition as you would for a GPT installation.

Then, again by selecting [FILE]ada0s2[/FILE] and selecting Create, make a swap slice:
Code: Select all
Type: freebsd-swap
Size: <whatever you like, I prefer 2x RAM>
Mountpoint and Label are greyed out. Select OK.

Feel free to make any other freebsd-ufs partitions (just not /boot) to fill out your freebsd partiton, then select Finish. The Handbook picks up from here, until you've committed, installed, rebooted. You'll notice [FILE]bsdinstall[/FILE] has overwritten the MBR without asking any questions during the install, so for a scary few minutes you won't be able to access Windows.

Login to root (or login with a user and su to root), and then bearing in mind you should replace '[FILE]ada0[/FILE]' with your HDD's device if different, execute
Code: Select all
boot0cfg -B ada0

to install the bootselect code to the MBR.

Rebooting, you should now be able to boot into Windows and FreeBSD.
Junior Member
Posts: 1
Joined: 14 Jan 2012, 23:51

Postby rafaelbsd » 18 Jul 2012, 17:26

Thanks for the excelent article!

Just want to make a small contribution:

I erased my Notebook, to correctly create the sizes of the partitions.

Then I installed firts Windows 7.

After that, with FreeBSD 9.0 DVD, when I started the Manual in the partition part, the system didn´t show me Windows 7 partition.

So I created it, using type NTFS, and then created the rest of the partitions as you told in the article.

The final partition schema was:
Code: Select all
  ada0s1 nfts
  ada0s2 BSD
    ada0s2a  /
    ada0s2b  swap

After install FreeBSD, I did reboot the system to install Windows 7, choosing the partition created with FreeBSD. Windows recognized it and the installations was successful.

After the Windows installation, I rebooted again with the FreeBSD 9 DVD, entered the LiveCD and executed the [FILE]boot0cfg -B ada0[/FILE].

Everything is working just fine!!!

PS: sorry about my poor english... ;-)
Junior Member
Posts: 1
Joined: 18 Jul 2012, 17:10

Postby shix » 22 Jul 2012, 00:39

Sorry for grave digging, but how would someone remove FreeBSD without having to mess up Windows?
Junior Member
Posts: 6
Joined: 12 May 2012, 01:36

Postby wblock@ » 22 Jul 2012, 03:08

Back up the entire disk first. The FreeBSD boot selector can be overwritten with Windows' [file]fixboot[/file] command. Or [file]fixmbr[/file]; I've never been clear on the difference. Windows should be able to see the FreeBSD slice, and eager to format it. It will then show up as another drive.
User avatar
Old Fart
Posts: 10227
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy

Postby rhish » 24 Nov 2012, 18:29

I had the same idea, thinking FOXBOOT and FIXMBR were basically the same. Then i discovered somethign interesting this morning.
During my dual install issues i went into WinXP recovery and got the following results.

FIXBOOT cannot find the system drive, or the drive specified is not valid.

so I then ran the other

This computer appears to have a non-standard or invalid master boot record.
FIXMBR may damage your partition tables if you proceed.
Are you sure you want to write a new MBR?

So, it would seem, FIXBOOT stops because it doesnt find a valid MBR, but FIXMBR wants to fix the situations?
Junior Member
Posts: 77
Joined: 16 Jun 2011, 05:23

Postby htutt » 25 Nov 2012, 13:21

I think that [FILE]C:\> fixboot[/FILE] doesn't need for Windows XP to fix master boot record, and just need [FILE]C:\> fixmbr[/FILE].
But for Windows 7, it needs both commands;
[FILE]C:\>bootrec /fixboot
C:\>bootrec /fixmbr[/FILE]
Junior Member
Posts: 46
Joined: 22 Sep 2011, 14:27

Postby scottro » 12 Jan 2013, 18:33

Having been away from FreeBSD for awhile, I was having a lot of trouble with BSD install and partitioning under an MBR when not using the same disk. This was the first thing I came across that fixed it for me, thank you. I did it under Linux, but it didn't (using 9.1) install the bootloader--not sure what step I missed. However, I was able to easily boot by adding it to a Linux grub2.

Most of what I found prior to this assumed that either one was using the whole disk or at least wanted to use GPT.
Posts: 181
Joined: 17 Nov 2008, 14:12

Postby ShelLuser » 15 Oct 2013, 22:10

Very nice article. Strict, to the point and still very usable.

Today I was trying to help a family member out with an Linux (Debian-like, I think it was Ubuntu) environment which had gone awol. It was a bit of a geek problem, but he was using his own (plain) boot manager he once wrote, which worked perfect with Lilo (which used 1 sector in the boot record due to it's 2 stage boot process) whereas the now commonly used Grub takes up a whole lot more.

Long story cut a little bit shorter: I was looking at a Linux environment which had to be bootstrapped, but with a preference for Lilo which was also hard to satisfy. Not sure what went wrong; but Lilo did not like the partition table for some reason.

And because he mostly used the Linux environment to clean up his windows environment (temporary internet files for example, which often have extremely long file names) I figured that FreeBSD should be able to cope just as well. # pkg_add -r should be perfectly usable.

The only problem was booting, and your article nailed it perfectly.

It even turned into a double win. Not only did this approach work flawlessly; the new boot menu (I think this is /boot/boot0) is also exactly 1 sector in size; just like Lilo used to be.

Which means so much that my relative can now probably copy the new boot sector and implement it in his own boot menu so that he can continue to boot happily ever after ;)

Alas, thanks again for a very straight to the point howto.
User avatar
Senior Member
Posts: 1001
Joined: 17 Apr 2013, 03:43
Location: Netherlands

Return to Howtos & FAQs (Moderated)

Who is online

Users browsing this forum: No registered users and 1 guest