From owner-freebsd-doc@FreeBSD.ORG Wed Jun 6 11:14:02 2012 Return-Path: Delivered-To: doc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E53AF106564A; Wed, 6 Jun 2012 11:14:01 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) by mx1.freebsd.org (Postfix) with ESMTP id C49B68FC0C; Wed, 6 Jun 2012 11:13:58 +0000 (UTC) Received: from alph.allbsd.org (p4242-ipbf1504funabasi.chiba.ocn.ne.jp [118.7.211.242]) (authenticated bits=128) by mail.allbsd.org (8.14.5/8.14.5) with ESMTP id q56BDYUV013550; Wed, 6 Jun 2012 20:13:46 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.14.4/8.14.4) with ESMTP id q56BDURC035997; Wed, 6 Jun 2012 20:13:31 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Wed, 06 Jun 2012 20:07:35 +0900 (JST) Message-Id: <20120606.200735.1551208261335301113.hrs@allbsd.org> To: ae@FreeBSD.org From: Hiroki Sato In-Reply-To: <4FCF3021.5070802@FreeBSD.org> References: <20120606.185023.497714372668376681.hrs@allbsd.org> <4FCF3021.5070802@FreeBSD.org> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.4.50 on Emacs 23.4 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart0(Wed_Jun__6_20_07_36_2012_770)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.97.4 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (mail.allbsd.org [133.31.130.32]); Wed, 06 Jun 2012 20:13:47 +0900 (JST) X-Spam-Status: No, score=-98.8 required=13.0 tests=CONTENT_TYPE_PRESENT, RCVD_IN_RP_RNBL,USER_IN_WHITELIST autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on gatekeeper.allbsd.org Cc: doc@FreeBSD.org Subject: Re: Handbook mirroring section X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jun 2012 11:14:02 -0000 ----Security_Multipart0(Wed_Jun__6_20_07_36_2012_770)-- Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Jun__6_20_07_36_2012_266)--" Content-Transfer-Encoding: 7bit ----Next_Part(Wed_Jun__6_20_07_36_2012_266)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit "Andrey V. Elsukov" wrote in <4FCF3021.5070802@FreeBSD.org>: ae> On 06.06.2012 13:50, Hiroki Sato wrote: ae> > Thanks, I will review the new version. ae> > ae> > BTW, do you (or anyone) know the common failure pattern when trying ae> > to use GPT + gmirror of the whole disk? ae> ae> There was a warning from the gptboot about corrupted backup GPT header. ae> But now the behavior has changed with r234692 and later it has been ae> merged to stable. So, when you are doing all in the right way - it should work. ae> ae> But: ae> 1. When geom_mirror module is not loaded GEOM_PART will complain that the ae> backup GPT header is not in the last LBA and partition table will be marked ae> as CORRUPT. The recover operation will destroy the GEOM_MIRROR's metadata. ae> ae> 2. If primary GPT header or table become damaged, then gptboot will not ae> detect GPT because the backup GPT header is not in the last LBA. So, the ae> system will not boot. Thanks, I see. Do you think the attached patch is too aggressive for the problem 2? The value of altlba should be matched with one in the original secondary header when the primary header is corrupted and the secondary header is looked up in this way. -- Hiroki ----Next_Part(Wed_Jun__6_20_07_36_2012_266)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="boot-gpt.20120606-1.diff" Index: sys/boot/common/gpt.c =================================================================== --- sys/boot/common/gpt.c (revision 235714) +++ sys/boot/common/gpt.c (working copy) @@ -40,6 +40,7 @@ #include "gpt.h" #define MAXTBLENTS 128 +#define GEOM_MAGIC "GEOM::" static struct gpt_hdr hdr_primary, hdr_backup, *gpthdr; static uint64_t hdr_primary_lba, hdr_backup_lba; @@ -345,8 +346,18 @@ altlba = hdr_primary.hdr_lba_alt; } else { altlba = drvsize(dskp); - if (altlba > 0) - altlba--; + if (altlba > 0) { + do { + altlba--; + /* + * Check GEOM metadata and decrement + * the altlba if found. + */ + if (drvread(dskp, secbuf, altlba, 1) != 0) + break; + } while (memcmp(secbuf, GEOM_MAGIC, + sizeof(GEOM_MAGIC) - 1) == 0); + } } if (altlba == 0) printf("%s: unable to locate backup GPT header\n", BOOTPROG); ----Next_Part(Wed_Jun__6_20_07_36_2012_266)---- ----Security_Multipart0(Wed_Jun__6_20_07_36_2012_770)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEABECAAYFAk/POfgACgkQTyzT2CeTzy0jOQCfW2/q3Ko3pDoqWAh2u9FnkDST 2VsAn0VNrwfslzqJVLfHNusq2C2Ash3r =+Fo5 -----END PGP SIGNATURE----- ----Security_Multipart0(Wed_Jun__6_20_07_36_2012_770)----