Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
UEFI refuses to remember boot order (Lenovo ideacentre B550)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Fri Oct 21, 2016 6:57 am    Post subject: UEFI refuses to remember boot order (Lenovo ideacentre B550) Reply with quote

For a long time now I'm trying to get UEFI in my desktop to boot my bootloader instead of microsoft one. I've learned how to create correct Boot entries (I was missing "-e 3" option). Still UEFI simply overrides BootOrder changes and restores and then uses the original value. Any idea why this might be happening? The Boot entries I create stay available, they just get deleted from BootOrder.
Back to top
View user's profile Send private message
324874
Apprentice
Apprentice


Joined: 26 Jul 2014
Posts: 168

PostPosted: Sat Oct 22, 2016 5:36 pm    Post subject: Reply with quote

The system firmware may delete a boot entry if something goes wrong or, as a security functionality, "block" the boot option until this one is certified.
(Maybe there are other reasons.) You should try to authentify the UEFI image, thanks to a feature, located in the setup menu of the system firmware.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Mon Oct 24, 2016 7:19 am    Post subject: Reply with quote

Thanks for the hint. Maybe you also know, where can I find this authentication functionality in the system firmware? I've searched through BIOS setup, but couldn't find anything there.
Back to top
View user's profile Send private message
324874
Apprentice
Apprentice


Joined: 26 Jul 2014
Posts: 168

PostPosted: Mon Oct 24, 2016 12:25 pm    Post subject: Reply with quote

I don't know where you can find this functionnality in the setup utility because there are various implementations [I give a tip below]. In my case, I had to use this functionnality to load Gentoo.
This functionnality is related to the Secure Boot mode (cf. chap. 30 of UEFI spec.) [see the note below]. The boot entry remains valid even after the deactivation of the Secure Boot mode.

In the InsydeH20 firmware of my computer, the functionnality is named "Select an UEFI file as trusted for executing".

My feeling is that many people may have issues with UEFI because they haven't enough knowledges. I work on the specification to be able writing a guide.
Unfortunately, I'm not in the better situation because I have to acquire knowledge (memory management, the C language programming, hardware architecture, etc.).
However, I'm happy to do this because I have issues with some UEFI mechanisms and I think a guide may be useful for other people.

Note: I give the reference to a part of the UEFI specification but I don't think this can be useful if we haven't previous knowledges about UEFI. My thought is that a global understanding about UEFI may be useful.
Tip: If I were you, I will ask to the Lenovo tech support how to use the "UEFI Image Validation" (related to the platform firmware) to add another trusted OS.

Best regards, feng.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Tue Oct 25, 2016 7:37 am    Post subject: Reply with quote

Ok. Thank you again. I'll try to dig around secure boot in my setup.

On the side note. I've tried to read UEFI specs but they are too long and contain too many things. One needs lots of time to actually find relevant parts. What is worse, it seems that not all UEFI implementations completely support those specs, plus there are some older/newer variants.

And when I contacted Lenovo, they offered me to resolve the issue over phone call, the price would be only 1.99 euro per minute :) I guess, I'll keep digging, anyway Microsoft restores the bootloader only 1-2 times per month :roll:
Back to top
View user's profile Send private message
mjbjr
Apprentice
Apprentice


Joined: 02 Mar 2003
Posts: 233

PostPosted: Tue Oct 25, 2016 8:29 am    Post subject: Reply with quote

this may help you:

Linux on UEFI:
A Quick Installation Guide

http://www.rodsbooks.com/linux-uefi/
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Fri Oct 28, 2016 1:21 pm    Post subject: Reply with quote

I've carefully gone through Setup utility. There's nothing about changing boot order there. The page responsible for setting Device boot order shows that from the hard drive the Windows Bootloader shall be called. No other bootloaders are present in the list, and there's no way to add anything to this list. Searching internet I've found lot's of articles saying that on many Lenovo and HP computers UEFI is broken. It has hardcoded Boot Order and it is not possible to change it. I guess my computer is no different from the rest :)
Back to top
View user's profile Send private message
324874
Apprentice
Apprentice


Joined: 26 Jul 2014
Posts: 168

PostPosted: Fri Oct 28, 2016 5:14 pm    Post subject: Reply with quote

All OS loaders and applications will be stored in subdirectories below EFI. The bootloader must be placed in \EFI\Gentoo\ [cf. note] on the ESP (EFI System Partition).
I don't think the Lenovo or HP 's system firmwares are broken. Moreover, all (UEFI) system firmwares must be compliant with the UEFI specification.
Probably, we didn't find how to use the platform firmware.

Note: The above notation (in the brown color) is related to UEFI. Relative to Gentoo: /boot/EFI/Gentoo or /boot/efi/EFI/Gentoo depending on the mount point of the ESP.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5761

PostPosted: Fri Oct 28, 2016 10:25 pm    Post subject: Re: UEFI refuses to remember boot order (Lenovo ideacentre B Reply with quote

v_andal wrote:
(I was missing "-e 3" option)

From what command?

Try this: install efibootmgr. Run it without args to see the current boot order. Run e.g. `efibootmgr -o 2,1,0` to set a new permanent one. See if it sticks after rebooting.
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 501

PostPosted: Sun Oct 30, 2016 3:07 pm    Post subject: Reply with quote

I've had a similar issue with an intel motherboard. Solution was to create a Directory "Boot" in the ESP, and place an arbitrary EFI file (for instance grub or a linux kernel with EFI stub built in) as "bootx64.efi" in there. Then, and only then, did EFI remember boot settings.

The ESP looks like this:

EFI/Boot/bootx64.efi
EFI/Gentoo/grubx64.efi
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Mon Oct 31, 2016 8:13 am    Post subject: Re: UEFI refuses to remember boot order (Lenovo ideacentre B Reply with quote

Ant P. wrote:
v_andal wrote:
(I was missing "-e 3" option)

From what command?

Try this: install efibootmgr. Run it without args to see the current boot order. Run e.g. `efibootmgr -o 2,1,0` to set a new permanent one. See if it sticks after rebooting.


This is option for efibootmgr. Without it, the entries were created incorrectly on my system.

I've done the test that you've described already multiple times trying to get it to remember different boot order. UEFI simply overrides my changes.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Mon Oct 31, 2016 8:15 am    Post subject: Reply with quote

roarinelk wrote:
I've had a similar issue with an intel motherboard. Solution was to create a Directory "Boot" in the ESP, and place an arbitrary EFI file (for instance grub or a linux kernel with EFI stub built in) as "bootx64.efi" in there. Then, and only then, did EFI remember boot settings.

The ESP looks like this:

EFI/Boot/bootx64.efi
EFI/Gentoo/grubx64.efi


Hm. I haven't tried this yet. So far I've used EFI/refind/bootx64.efi... I'll try to rename it to EFI/Boot/bootx64.efi
I guess this is not according to specifications :)
Back to top
View user's profile Send private message
324874
Apprentice
Apprentice


Joined: 26 Jul 2014
Posts: 168

PostPosted: Mon Oct 31, 2016 5:06 pm    Post subject: Reply with quote

I searched a little further in the specification: the first part of the "6. Services - Boot Services" section is related to the platform firmware features;
in the second part, follows the explanation about the use of the services (section 6.4 "Image services" p.209). I'll watch in the "3. Boot Manager" section too.

I would like extract information using the efivarfs interface (see Accessing UEFI variables - Intel weblog) but I don't know (understand) how to read/find the values of variables.
In fact, we can use this interface instead of efibootmgr to create boot entries. If you can, it would be good to give us information about the boot entry using efivarfs.

I'm curious: could you give us the result of efibootmgr -v for the interesting boot entry?

Note: Each protocol contains a description (see section "1.8 Conventions Used in this document"). The list of protocols defined by the specification is on p.44

Edition: The first and last paragraph is a bit user centric! I tried to give some useful informations to configure in "deep" the platform firmware.
It seems an hex dump is used to read information related with runtime variables.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Wed Nov 02, 2016 8:37 am    Post subject: Reply with quote

feng wrote:

I would like extract information using the efivarfs interface (see Accessing UEFI variables - Intel weblog) but I don't know (understand) how to read/find the values of variables.


Well, reading the value is trivial. Just read the content of appropriate file. Understanding/interpreting the content is completely different story. I guess the format of the variable value shall be described in specs.

Quote:

In fact, we can use this interface instead of efibootmgr to create boot entries. If you can, it would be good to give us information about the boot entry using efivarfs.


Of course I can do it (and shall do it a bit later), but that shall be just hexdump. The interpretation is available via efibootmgr, I didn't find description for internal format of the variable in specs (they are too big and require too much time to study).

Quote:

I'm curious: could you give us the result of efibootmgr -v for the interesting boot entry?


I'll provide this as well.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Thu Nov 03, 2016 7:40 am    Post subject: Reply with quote

Ok. Here are the outputs of efibootmgr and content of EFI files

This is output of efibootmgr -v
Code:

BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,2001,2002,2003
Boot0000* Windows Boot Manager   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC
Boot0001* Windows Boot Manager   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC
Boot0002* Windows Boot Manager   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC
Boot0003* UEFI Generic Boot   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(4,0,0)/CDROM(1,0x2f021,0xb40)/File(\EFI\BOOT\BOOTX64.EFI)RC
Boot0004* Windows Boot Manager   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC
Boot0005* Windows Boot Manager   HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...]................
Boot0006* Windows Boot Manager   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC
Boot0007* HL-DT-ST DVDRAM GU90N   BBS(CDROM,Pÿ,0x500)................-.t.......t.A.t....C...................................
Boot0009* Refind   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\refind\bootx64.efi)
Boot000C* UEFI Generic Boot   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(4,0,0)/CDROM(1,0x2f021,0xb40)/File(\EFI\BOOT\BOOTX64.EFI)RC
Boot000D* Windows Boot Manager   PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)/HD(2,GPT,31948914-b49f-482c-8106-c5e2f1edd905,0x1f4800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC


This is the content of Boot0000 which is booted by UEFI

Code:

less /sys/firmware/efi/efivars/Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c

00000000  07 00 00 00 01 00 00 00  90 00 57 00 69 00 6e 00  |..........W.i.n.|
00000010  64 00 6f 00 77 00 73 00  20 00 42 00 6f 00 6f 00  |d.o.w.s. .B.o.o.|
00000020  74 00 20 00 4d 00 61 00  6e 00 61 00 67 00 65 00  |t. .M.a.n.a.g.e.|
00000030  72 00 00 00 02 01 0c 00  d0 41 03 0a 00 00 00 00  |r........A......|
00000040  01 01 06 00 02 1f 03 12  0a 00 00 00 00 00 00 00  |................|
00000050  04 01 2a 00 02 00 00 00  00 48 1f 00 00 00 00 00  |..*......H......|
00000060  00 20 08 00 00 00 00 00  14 89 94 31 9f b4 2c 48  |. .........1..,H|
00000070  81 06 c5 e2 f1 ed d9 05  02 02 04 04 46 00 5c 00  |............F.\.|
00000080  45 00 46 00 49 00 5c 00  4d 00 69 00 63 00 72 00  |E.F.I.\.M.i.c.r.|
00000090  6f 00 73 00 6f 00 66 00  74 00 5c 00 42 00 6f 00  |o.s.o.f.t.\.B.o.|
000000a0  6f 00 74 00 5c 00 62 00  6f 00 6f 00 74 00 6d 00  |o.t.\.b.o.o.t.m.|
000000b0  67 00 66 00 77 00 2e 00  65 00 66 00 69 00 00 00  |g.f.w...e.f.i...|
000000c0  7f ff 04 00 52 43                                 |....RC|
000000c6


This is the content of Boot0009 which I've created to boot rEFInd instead on
Microsoft.

Code:

less /sys/firmware/efi/efivars/Boot0009-8be4df61-93ca-11d2-aa0d-00e098032b8c

00000000  07 00 00 00 01 00 00 00  7e 00 52 00 65 00 66 00  |........~.R.e.f.|
00000010  69 00 6e 00 64 00 00 00  02 01 0c 00 d0 41 03 0a  |i.n.d........A..|
00000020  00 00 00 00 01 01 06 00  02 1f 03 12 0a 00 00 00  |................|
00000030  00 00 00 00 04 01 2a 00  02 00 00 00 00 48 1f 00  |......*......H..|
00000040  00 00 00 00 00 20 08 00  00 00 00 00 14 89 94 31  |..... .........1|
00000050  9f b4 2c 48 81 06 c5 e2  f1 ed d9 05 02 02 04 04  |..,H............|
00000060  34 00 5c 00 45 00 46 00  49 00 5c 00 72 00 65 00  |4.\.E.F.I.\.r.e.|
00000070  66 00 69 00 6e 00 64 00  5c 00 62 00 6f 00 6f 00  |f.i.n.d.\.b.o.o.|
00000080  74 00 78 00 36 00 34 00  2e 00 65 00 66 00 69 00  |t.x.6.4...e.f.i.|
00000090  00 00 7f ff 04 00                                 |......|
00000096
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Thu Nov 03, 2016 2:28 pm    Post subject: Reply with quote

Looks like I was able to find the description of format for BootXXXX files. It is in UEFI specification. One should search for EFI_LOAD_OPTION. Just for reference:

Code:

4 bytes are the attributes of variable.
4 bytes are the attributes of the Boot record. If bit 1 is set, then the record is active
2 bytes contain the length of FilePathList in bytes (little-endian)
Then comes NUL terminated description (UTF-16 string)
Then starts the FilePathList. Each element of that array is structure of type EFI_DEVICE_PATH_PROTOCOL. The total length is given by 2 bytes mentioned above.
Finally comes optional string that is passed to the loaded OS.


The EFI_DEVICE_PATH_PROTOCOL has following format
Code:

1 byte is type of record
1 byte is sub-type or record
2 bytes is total length of the record including the 4 bytes described here


So, after decoding the records for Boot0000 and Boot0009 provided in previous post, I can say, that they look identical, except for description, path to file and the optional string for loader.
Back to top
View user's profile Send private message
324874
Apprentice
Apprentice


Joined: 26 Jul 2014
Posts: 168

PostPosted: Thu Nov 10, 2016 8:11 pm    Post subject: Reply with quote

Good evening! Thanks again v_andal for your patience.

I got a little misguided. I can't understand the content of the file Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c.
The UEFI spec. promotes the use of an advanced programming language to implement the platform firmware. So, I think this data are in a too lower level to be directly interpreted.
I believe we can get information about the boot options by a programmatic approach. Indeed, the UEFI spec. defines abstract interfaces through procedures.
In other words, programmers can thought in a more accessible ways (they should think about the problem and not about the state of the machine).

This example shows a data manipulation.

Maybe, your issue is related to efibootmgr. I read we can use a uefi shell (bcfg command?) to modify boot entries (see the Jepio's wiki page, Arch wiki, UEFI shell binary).

Best regards, feng.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Fri Nov 11, 2016 7:20 am    Post subject: Reply with quote

Actually, the description of format, that I provided above is for the Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c. So I could decipher the content and compare it with the entries that efibootmgr creates. The created entries are valid and don't have any problem. In fact, Microsoft has created already 3 or 4 extra entries with exactly the same content as Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c. So, out of curiosity, I've changed the boot order to point to one of those entries, just to see if UEFI does not like mine. The result was the same, the firmware restored BootOrder to 0000, 2001, 2002, 2003. So, now I'm 100% sure that Lenovo simply ignores UEFI specs in this respect.

Edit. Additional tests show, that UEFI from Lenovo not only hardcodes the BootOrder, but also the Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c file. If I override it, after reboot, the content points to Microsoft loader again.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum