Author: allanjude (doc committer)
Date: Wed Jul 15 02:23:55 2015
New Revision: 285594
URL: https://svnweb.freebsd.org/changeset/base/285594

Log:
  Add a new option to gpart(8) to fix Lenovo BIOS boot issue
  
  PR:           184910
  Reviewed by:  ae, wblock
  Approved by:  marcel
  MFC after:    3 days
  Relnotes:     yes
  Sponsored by: ScaleEngine Inc.
  Differential Revision:        https://reviews.freebsd.org/D3065

Modified:
  head/sbin/geom/class/part/gpart.8
  head/sys/geom/part/g_part_gpt.c

Modified: head/sbin/geom/class/part/gpart.8
==============================================================================
--- head/sbin/geom/class/part/gpart.8   Wed Jul 15 01:04:54 2015        
(r285593)
+++ head/sbin/geom/class/part/gpart.8   Wed Jul 15 02:23:55 2015        
(r285594)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 5, 2015
+.Dd July 14, 2015
 .Dt GPART 8
 .Os
 .Sh NAME
@@ -933,6 +933,12 @@ start-up script.
 See
 .Xr gptboot 8
 for more details.
+.It Cm lenovofix
+Setting this attribute overwrites the Protective MBR with a new one where
+the 0xee partition is the second, rather than the first record.
+This resolves a BIOS compatibility issue with some Lenovo models including the
+X220, T420, and T520, allowing them to boot from GPT partitioned disks
+without using EFI.
 .El
 .Pp
 The scheme-specific attributes for MBR:

Modified: head/sys/geom/part/g_part_gpt.c
==============================================================================
--- head/sys/geom/part/g_part_gpt.c     Wed Jul 15 01:04:54 2015        
(r285593)
+++ head/sys/geom/part/g_part_gpt.c     Wed Jul 15 02:23:55 2015        
(r285594)
@@ -1007,6 +1007,7 @@ g_part_gpt_setunset(struct g_part_table 
 {
        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 
                        }
                }
                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)
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to