From owner-freebsd-bugs@FreeBSD.ORG Sat May 16 20:10:05 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73A951065679 for ; Sat, 16 May 2009 20:10:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 4FED28FC1D for ; Sat, 16 May 2009 20:10:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GKA5U9018411 for ; Sat, 16 May 2009 20:10:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n4GKA5Sf018410; Sat, 16 May 2009 20:10:05 GMT (envelope-from gnats) Resent-Date: Sat, 16 May 2009 20:10:05 GMT Resent-Message-Id: <200905162010.n4GKA5Sf018410@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Christoph Langguth Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FEBB106566B for ; Sat, 16 May 2009 20:03:34 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 24D178FC12 for ; Sat, 16 May 2009 20:03:34 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GK3XoA093545 for ; Sat, 16 May 2009 20:03:33 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n4GK3XVW093544; Sat, 16 May 2009 20:03:33 GMT (envelope-from nobody) Message-Id: <200905162003.n4GK3XVW093544@www.freebsd.org> Date: Sat, 16 May 2009 20:03:33 GMT From: Christoph Langguth To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/134590: [request][patch] Bootloader support for hybrid MBR/GPT partitioning X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:10:06 -0000 >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 >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat May 16 20:10:04 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Christoph Langguth >Release: 7.2-RELEASE, 8.0-CURRENT >Organization: >Environment: FreeBSD marvin 8.0-CURRENT FreeBSD 8.0-CURRENT #12: Sat May 16 18:33:46 UTC 2009 root@marvin:/usr/obj/usr/src/sys/MARVIN amd64 >Description: 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. >How-To-Repeat: 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) >Fix: 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/biosdisk.c.org 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) part++; - else if (dp[i].dp_typ != 0x00) + else if ((part != 1) && (dp[i].dp_typ != 0x00)) return (EINVAL); } if (part != 1) >Release-Note: >Audit-Trail: >Unformatted: