From owner-freebsd-geom@FreeBSD.ORG Fri Jul 10 19:03:18 2009 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02A0E106566B for ; Fri, 10 Jul 2009 19:03:18 +0000 (UTC) (envelope-from jeff+freebsd@wagsky.com) Received: from mail.wagsky.com (wildside.wagsky.com [75.101.96.15]) by mx1.freebsd.org (Postfix) with ESMTP id CC6728FC14 for ; Fri, 10 Jul 2009 19:03:17 +0000 (UTC) (envelope-from jeff+freebsd@wagsky.com) Received: from [192.168.208.129] (mail.guidewire.com [69.108.213.131]) by mail.wagsky.com (Postfix) with ESMTPSA id 37BDA1E4192; Fri, 10 Jul 2009 12:03:17 -0700 (PDT) Message-ID: <4A579076.5070008@wagsky.com> Date: Fri, 10 Jul 2009 12:03:18 -0700 From: Jeff Kletsky User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: freebsd-geom@freebsd.org References: <4A578E3F.8050305@wagsky.com> In-Reply-To: <4A578E3F.8050305@wagsky.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: 7.x and 8.0 gpt and gpart GPT PMBR prevents Intel boot X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2009 19:03:18 -0000 It appears to me that the PMBR being used both by gpt and gpart is causing boot problems with current Intel hardware. There appear to be two issues that can cause difficulties: * The "start" of the PMBR is 0xffffff * The PMBR is not marked "bootable" by gpt or gpart In particular, it has been confirmed that it is not possible to format a GPT drive that will boot on an Intel D945GCLF2 with current BIOS (and may be the causes for the observed "freezes" at boot). Both these issues have been previously documented: These two PMBR excerpts illustrate the changes required: This is the "stock" PMBR generated by gpart for a 500 GB SATA drive. It does *not* allow the BIOS to boot.(FreeBSD 7.2-RELEASE-p2) 000001b0: 9090 9090 9090 9090 0000 0000 0000 00ff ................ 000001c0: ffff eeff ffff 0100 0000 2e60 383a 0000 ...........`8:.. 000001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U. This is a hand-modified version of the PMBR installed on the same drive that does permit the BIOS to boot. 000001b0: 9090 9090 9090 9090 0000 0000 0000 8001 ................ 000001c0: 0100 eeff ffff 0100 0000 2e60 383a 0000 ...........`8:.. 000001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U. Note that the "bootable" flag has been set (0x80) and the start of the partition has been set to the beginning of the disk (0x010100). Without the 0x80 flag also set, the D945GCLF2 BIOS does not identify any bootable drives. The Intel specification for EFI boot does indicate (pp 374-375) that 0xffffff is to be used when the start of the partition can't be represented using CHS notation. However, this PMBR refers to the entire disk, arguably to prevent legacy systems from overwriting it (Protective Master Boot Record), but apparently also "reputable" BIOS manufacturers are producing current systems that key off the information as well. The PR indicates patches for the CHS issue for gpt. For gpart, the code is in /usr/src/sys/geom/part/g_part_gpt.c and, I believe, should be modified to read le16enc(table->mbr + DOSMAGICOFFSET, DOSMAGIC); table->mbr[DOSPARTOFF + 1] = 0x01; /* shd */ table->mbr[DOSPARTOFF + 2] = 0x01; /* ssect */ table->mbr[DOSPARTOFF + 3] = 0x00; /* scyl */ table->mbr[DOSPARTOFF + 4] = 0xee; /* typ */ table->mbr[DOSPARTOFF + 5] = 0xff; /* ehd */ table->mbr[DOSPARTOFF + 6] = 0xff; /* esect */ table->mbr[DOSPARTOFF + 7] = 0xff; /* ecyl */ le32enc(table->mbr + DOSPARTOFF + 8, 1); /* start */ le32enc(table->mbr + DOSPARTOFF + 12, MIN(last, 0xffffffffLL)); which will make it consistent with MBR content for the first partition on Windows machines (protecting GPT drives from inadvertent modification on non-GPT-aware platforms), as well as the patch suggested in PR 115406. (Code still unmodified in HEAD v1.16) As to marking the partition bootable, there is a question of where the most appropriate place might be and if a flag to override should be made available. In my opinion, it should be so marked when a GPT boot segment is added to the drive as well as when either drive-level or partition-level boot code is written, with a command-line option to not change the "bootable" flag in the PMBR for these conditions. In my opinion, these issues should be considered for inclusion in the 8.0-RELEASE -- at the very least, the 0xffffff issue, as it cannot easily be resolved from the command line. Thanks, Jeff