Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Jun 2012 20:07:35 +0900 (JST)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        ae@FreeBSD.org
Cc:        doc@FreeBSD.org
Subject:   Re: Handbook mirroring section
Message-ID:  <20120606.200735.1551208261335301113.hrs@allbsd.org>
In-Reply-To: <4FCF3021.5070802@FreeBSD.org>
References:  <alpine.BSF.2.00.1206052220390.10777@wonkity.com> <20120606.185023.497714372668376681.hrs@allbsd.org> <4FCF3021.5070802@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----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" <ae@FreeBSD.org> 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)----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120606.200735.1551208261335301113.hrs>