Index: sbin/geom/class/part/geom_part.c =================================================================== --- sbin/geom/class/part/geom_part.c +++ sbin/geom/class/part/geom_part.c @@ -120,10 +120,11 @@ }, { "create", 0, gpart_issue, { { 's', "scheme", NULL, G_TYPE_STRING }, + { 'i', "index", G_VAL_OPTIONAL, G_TYPE_NUMBER }, { 'n', "entries", G_VAL_OPTIONAL, G_TYPE_NUMBER }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, - "-s scheme [-n entries] [-f flags] provider" + "-s scheme [-i index] [-n entries] [-f flags] provider" }, { "delete", 0, gpart_issue, { { 'i', GPART_PARAM_INDEX, NULL, G_TYPE_NUMBER }, Index: sbin/geom/class/part/gpart.8 =================================================================== --- sbin/geom/class/part/gpart.8 +++ sbin/geom/class/part/gpart.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 5, 2015 +.Dd July 12, 2015 .Dt GPART 8 .Os .Sh NAME @@ -61,6 +61,7 @@ .Nm .Cm create .Fl s Ar scheme +.Op Fl i Ar index .Op Fl n Ar entries .Op Fl f Ar flags .Ar provider @@ -264,6 +265,12 @@ .Pp Additional options include: .Bl -tag -width 10n +.It Fl i Ar index +Offset in the pMBR partition table to write the protection GPT +partition to. +This is used to work around a bug in some Lenovo BIOSs (x220, t420). +Valid values are 0 - 3. +Only application to GPT partitioning schemes. .It Fl n Ar entries The number of entries in the partition table. Every partitioning scheme has a minimum and maximum number of entries. Index: sys/geom/part/g_part.c =================================================================== --- sys/geom/part/g_part.c +++ sys/geom/part/g_part.c @@ -1567,7 +1567,7 @@ } else if (!strcmp(verb, "create")) { ctlreq = G_PART_CTL_CREATE; mparms |= G_PART_PARM_PROVIDER | G_PART_PARM_SCHEME; - oparms |= G_PART_PARM_ENTRIES; + oparms |= G_PART_PARM_ENTRIES | G_PART_PARM_INDEX; } break; case 'd': Index: sys/geom/part/g_part_gpt.c =================================================================== --- sys/geom/part/g_part_gpt.c +++ sys/geom/part/g_part_gpt.c @@ -287,11 +287,11 @@ } static void -gpt_create_pmbr(struct g_part_gpt_table *table, struct g_provider *pp) +gpt_create_pmbr(struct g_part_gpt_table *table, struct g_provider *pp, int idx) { bzero(table->mbr + DOSPARTOFF, DOSPARTSIZE * NDOSPART); - gpt_write_mbr_entry(table->mbr, 0, 0xee, 1, + gpt_write_mbr_entry(table->mbr, idx, 0xee, 1, MIN(pp->mediasize / pp->sectorsize - 1, UINT32_MAX)); le16enc(table->mbr + DOSMAGICOFFSET, DOSMAGIC); } @@ -377,7 +377,7 @@ disable: table->bootcamp = 0; - gpt_create_pmbr(table, pp); + gpt_create_pmbr(table, pp, 0); } static struct gpt_hdr * @@ -646,7 +646,7 @@ pp->sectorsize) return (ENOSPC); - gpt_create_pmbr(table, pp); + gpt_create_pmbr(table, pp, gpp->gpp_index); /* Allocate space for the header */ table->hdr = g_malloc(sizeof(struct gpt_hdr), M_WAITOK | M_ZERO); @@ -995,7 +995,7 @@ table = (struct g_part_gpt_table *)basetable; pp = LIST_FIRST(&basetable->gpt_gp->consumer)->provider; - gpt_create_pmbr(table, pp); + gpt_create_pmbr(table, pp, 0); g_gpt_set_defaults(basetable, pp); basetable->gpt_corrupt = 0; return (0);