Bug 203108

Summary: Thinkpad T420s will not boot GPT formatted disks.
Product: Base System Reporter: LW <ipc>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Many People CC: allanjude, emaste, kevinz5000, vidwer+fbsdbugs
Priority: ---    
Version: 10.2-RELEASE   
Hardware: amd64   
OS: Any   

Description LW 2015-09-14 20:02:00 UTC
Apparently the issue has been fixed on the Thinkpad T420, but the T420s does not boot a GPT formatted hard disk drive (Root on ZFS).
Comment 1 crest 2015-09-15 10:05:48 UTC
It is a known problem that the X220 and T420 refuse to boot in legacy mode from GPT formatted disks. I suspect that the T420s is affected as well. You can either boot in legacy mode from a MBR + bsdlabel formatted disk or boot in EFI mode with the experimental UFS only EFI bootloader.
Comment 2 Allan Jude freebsd_committer freebsd_triage 2015-10-15 19:39:06 UTC
When doing the root-of-zfs install, cycle the partition type option from 'GPT' to 'GPT + LenovoFix' and see if that solves it.

If it does, attach the output of:
kenv | grep smbios

to this ticket, and I'll add your hardware to the blacklist
Comment 3 Kevin Zheng 2018-12-25 18:13:40 UTC
Alternatively, gpart set -a lenovofix on your disk.
Comment 4 vidwer+fbsdbugs 2020-10-29 02:11:46 UTC
(In reply to Allan Jude from comment #2)
> When doing the root-of-zfs install, cycle the partition type option from 'GPT' to 'GPT + LenovoFix' and see if that solves it.

On a Lenovo ThinkPad E560, I tried adding 'ThinkPad E560' to this script:
https://github.com/freebsd/freebsd/blob/master/usr.sbin/bsdinstall/scripts/auto#L225

To install on UFS, one can select MBR or GPT. Only MBR will boot.

To install on ZFS, there are more options.
Using GPT: BIOS, UEFI, and BIOS+UEFI. Neither option will provide a bootable installation.
Using MBR: BIOS, GPT + Active, and Lenovo fix. Neither option will provide a bootable installation as well.
Comment 5 vidwer+fbsdbugs 2020-11-03 14:27:55 UTC
firmware can boot with using 'uefi only', 'legacy only', or 'both'
For 'both', legacy boot priority is preset to 'legacy first' and CSM support can't be disabled(?).

Here's my diff, and a partial decode of the first megabyte of the media that should be bootable:

diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
index a58a63f2f70..96d1d8f8e64 100755
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -222,7 +222,7 @@ if f_interactive; then
        case "$sys_maker" in
        "LENOVO")
                case "$sys_version" in
-               "ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520"|"ThinkPad W520"|"ThinkPad X1")
+               "ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520"|"ThinkPad W520"|"ThinkPad X1"|"ThinkPad E560")
                        dialog_workaround "$msg_lenovo_fix"
                        retval=$?
                        f_dprintf "lenovofix_prompt=[%s]" "$retval"

$ hexdump -C da0_pre-lenovofix.dd | grep ee | head
000001c0  02 00 ee ff ff ff 01 00  00 00 ff ef 7a 00 00 00  |............z...|
00005360  89 1d ee 5d 00 00 8b 0d  f8 5d 00 00 e3 0f 8d 7e  |...].....].....~|
00005690  10 8e ff ff 11 92 01 ee  01 00 01 94 02 ee 01 00  |................|
00005910  6a 10 ff 75 08 57 e8 ee  33 00 00 83 c4 0c 43 83  |j..u.W..3.....C.|
00005ee0  50 57 53 e8 47 2e 00 00  83 c4 0c 46 8b 45 08 8b  |PWS.G......F.E..|
00006ee0  b5 01 00 00 b9 96 04 00  00 2b 0d 44 99 01 00 b8  |.........+.D....|
00007610  cc cc 50 66 ba fb 03 b0  83 ee 80 ea 03 58 66 ef  |..Pf.........Xf.|
00007620  66 ba fb 03 b0 03 ee 42  b0 03 ee 42 31 c9 b5 80  |f......B...B1...|
00007650  ee c3 e8 0b 00 00 00 0f  84 f5 ff ff ff 80 ea 05  |................|
00007750  c1 ee 04 66 89 35 02 89  01 00 8b 5d 10 89 1d 04  |...f.5.....]....|
$ hexdump -C da0_post-lenovofix.dd | grep ee | head
000001d0  02 00 ee ff ff ff 01 00  00 00 ff ef 7a 00 00 00  |............z...|
00005360  89 1d ee 5d 00 00 8b 0d  f8 5d 00 00 e3 0f 8d 7e  |...].....].....~|
00005690  10 8e ff ff 11 92 01 ee  01 00 01 94 02 ee 01 00  |................|
00005910  6a 10 ff 75 08 57 e8 ee  33 00 00 83 c4 0c 43 83  |j..u.W..3.....C.|
00005ee0  50 57 53 e8 47 2e 00 00  83 c4 0c 46 8b 45 08 8b  |PWS.G......F.E..|
00006ee0  b5 01 00 00 b9 96 04 00  00 2b 0d 44 99 01 00 b8  |.........+.D....|
00007610  cc cc 50 66 ba fb 03 b0  83 ee 80 ea 03 58 66 ef  |..Pf.........Xf.|
00007620  66 ba fb 03 b0 03 ee 42  b0 03 ee 42 31 c9 b5 80  |f......B...B1...|
00007650  ee c3 e8 0b 00 00 00 0f  84 f5 ff ff ff 80 ea 05  |................|
00007750  c1 ee 04 66 89 35 02 89  01 00 8b 5d 10 89 1d 04  |...f.5.....]....|

$ hexdump -C da0_pre-lenovofix.dd | grep ee | egrep '01c0|01d0'
000001c0  02 00 ee ff ff ff 01 00  00 00 ff ef 7a 00 00 00  |............z...|
$ hexdump -C da0_post-lenovofix.dd | grep ee | egrep '01c0|01d0'
000001d0  02 00 ee ff ff ff 01 00  00 00 ff ef 7a 00 00 00  |............z...|
Comment 6 vidwer+fbsdbugs 2020-11-03 14:30:00 UTC
(In reply to vidwer+fbsdbugs from comment #5)
 gpart show da0
=>     40  8056752  da0  GPT  (3.8G)
       40     1024    1  freebsd-boot  (512K)
     1064  7650304    2  freebsd-ufs  (3.6G)
  7651368   403456    3  freebsd-swap  (197M)
  8054824     1968       - free -  (984K)
Comment 7 vidwer+fbsdbugs 2020-11-03 15:14:34 UTC
'kenv | grep smbios':
smbios.bios.reldate="12/01/2016"
smbios.bios.vendor="LENOVO"
smbios.bios.version="R00ET49W (1.24 )"
smbios.chassis.maker="LENOVO"
smbios.chassis.serial="PF0H5EVU"
smbios.chassis.tag="No Asset Information"
smbios.chassis.type="Notebook"
smbios.chassis.version="None"
smbios.memory.enabled="12582912"
smbios.planar.location="Not Available"
smbios.planar.maker="LENOVO"
smbios.planar.product="20EV0013MH"
smbios.planar.serial="L1HF61B047Z"
smbios.planar.tag="Not Available"
smbios.planar.version="SDK0J40705 WIN"
smbios.socket.enabled="1"
smbios.socket.populated="1"
smbios.system.family="ThinkPad E560"
smbios.system.maker="LENOVO"
smbios.system.product="20EV0013MH"
smbios.system.serial="/* serial */"
smbios.system.sku="LENOVO_MT_20EV_BU_Think_FM_ThinkPad E560"
smbios.system.uuid="/* uuid */"
smbios.system.version="ThinkPad E560"
smbios.version="2.8"