Index: sbin/geom/class/part/gpart.8 =================================================================== --- sbin/geom/class/part/gpart.8 +++ sbin/geom/class/part/gpart.8 @@ -933,6 +933,11 @@ See .Xr gptboot 8 for more details. +.It Cm lenovofix +Setting this attribute writes a new GPT pMBR with the 0xee partition in the 2nd +slot instead of the first. This resolves a BIOS compatibility issue in some +Lenovo models including the X220, T420, and T520, allowing them to boot from +GPT partitioned disks without EFI. .El .Pp The scheme-specific attributes for MBR: Index: sys/geom/part/g_part_gpt.c =================================================================== --- sys/geom/part/g_part_gpt.c +++ sys/geom/part/g_part_gpt.c @@ -1007,6 +1007,7 @@ { 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,22 @@ } } 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, 1, 0xee, 1, + MIN(pp->mediasize / pp->sectorsize - 1, UINT32_MAX)); + le16enc(table->mbr + DOSMAGICOFFSET, DOSMAGIC); + return (0); } if (entry == NULL)