bin/134590: [request][patch] Bootloader support for hybrid MBR/GPT partitioning

Christoph Langguth christoph at
Sat May 16 20:10:06 UTC 2009

>Number:         134590
>Category:       bin
>Synopsis:       [request][patch] Bootloader support for hybrid MBR/GPT partitioning
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 16 20:10:04 UTC 2009
>Originator:     Christoph Langguth
>Release:        7.2-RELEASE, 8.0-CURRENT
FreeBSD marvin 8.0-CURRENT FreeBSD 8.0-CURRENT #12: Sat May 16 18:33:46 UTC 2009     root at marvin:/usr/obj/usr/src/sys/MARVIN  amd64
When FreeBSD is installed on a GPT partition on a Multi-Boot Computer (Macbook Pro in this case), loader refuses to read the GPT table (and thus, to boot) if MBR partitions other than the protective EFI one are installed.

I have a quadruple-boot setup here, with MacOS, Windows, Linux, FreeBSD. The way that Bootcamp traditionally partitions the disk is not entirely compliant with the GPT scheme (I know...), because it allows additional entries in the MBR.

I have actually used this setup productively and not experienced any problems (as long as the MBR and GPT are "in sync" for the 4 first partitions, of course): MBR-only OSs such as Windows happily work with the limited information that they have, while GPT-aware ones ignore the MBR and use the GPT. This also goes for FreeBSD, with the only exception being the boot loader, actually: If unpatched, it fails to recognize the GPT partition (resorting to the MBR instead), and therefore fails to find the boot (and root) partitions.
Partition drive using GPT, and have the first 4 partitions of the GPT and MBR be in sync. (in sync meaning: have an EE partition as first MBR partition, but other ones as well). Install FreeBSD on a partition exclusively available in the GPT (i.e., partition number > 4)

let loader ignore any additional MBR partitions while scanning for the GPT table. The attached patch does this with a (IMO) minimal impact:
- it will still (correctly) fail to see the GPT if anything is logically wrong with it
- it will still fail if there is no, or more than one, EE partition
- it will still fail if the EE partition is not the first
- the only change is that it will silently accept other partitions being present in the MBR, yet still be able to recognize a GPT.

Patch attached with submission follows:

--- sys/boot/i386/libi386/	2009-05-16 19:36:22.000000000 +0000
+++ sys/boot/i386/libi386/biosdisk.c	2009-05-16 19:38:36.000000000 +0000
@@ -879,7 +879,7 @@
     for (i = 0; i < NDOSPART; i++) {
 	if (dp[i].dp_typ == 0xee)
-	else if (dp[i].dp_typ != 0x00)
+	else if ((part != 1) && (dp[i].dp_typ != 0x00))
 	    return (EINVAL);
     if (part != 1)


More information about the freebsd-bugs mailing list