From 10c80a84dab9d6dfc505ebcda9ca49b6caa78f90 Mon Sep 17 00:00:00 2001 From: allanjude Date: Tue, 21 Jul 2015 15:50:14 +0000 Subject: MFC: r285594 New partition flag for gpart, writes the 0xee partition in the pmbr in the second slot, rather than the first. Works around Lenovo legacy GPT boot issue PR: 184910 Approved by: re (gjb), marcel Relnotes: yes Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D3140 --- sys/geom/part/g_part_gpt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sys') diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index b331f84..d7650e9 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -1007,6 +1007,7 @@ g_part_gpt_setunset(struct g_part_table *basetable, { struct g_part_gpt_entry *entry; struct g_part_gpt_table *table; + struct g_provider *pp; uint8_t *p; uint64_t attr; int i; @@ -1036,6 +1037,21 @@ g_part_gpt_setunset(struct g_part_table *basetable, } } return (0); + } else if (strcasecmp(attrib, "lenovofix") == 0) { + /* + * Write the 0xee GPT entry to slot #1 (2nd slot) in the pMBR. + * This workaround allows Lenovo X220, T420, T520, etc to boot + * from GPT Partitions in BIOS mode. + */ + + if (entry != NULL) + return (ENXIO); + + pp = LIST_FIRST(&basetable->gpt_gp->consumer)->provider; + bzero(table->mbr + DOSPARTOFF, DOSPARTSIZE * NDOSPART); + gpt_write_mbr_entry(table->mbr, ((set) ? 1 : 0), 0xee, 1, + MIN(pp->mediasize / pp->sectorsize - 1, UINT32_MAX)); + return (0); } if (entry == NULL) -- cgit v1.1