Jump to content

Creating EFI Boot entries using bcdedit in Windows.


SoThOr
 Share

2 posts in this topic

Recommended Posts

This was spurred on from a discussion in the Clover General thread. Where there was a debate on bcdedit being able create/read/edit (U)EFI Boot entries. I didn't think it appropriate to post all this information there and somebody may want to make use of this and its likely to get lost in that massive thread.

 

Out of curiosity I decided to see if I could create an EFI entry using bcdedit. What can I say I like a challenge. :dev: Whilst is not a documented method by Microsoft, as it turns out in a round about way it IS possible to create an EFI entry using bcdedit and these are the steps I went through to add UEFI Shell located on a USB stick to the EFI entries. 

 

Third party software is available that can create and edit UEFI entries from Windows with better support and more features. I'm just making this information available in case those options are unavailable. 

 

DISCLAIMER - This is not a supported method. Use at your own risk. I recommend backing up your BCD/Firmware variables/settings beforehand.

 

1) Copy {bootmgr} entry.

C:\Windows\System32>bcdedit /copy {bootmgr} /d "UEFI Shell"
The entry was successfully copied to {34e8383c-73a7-11e9-9cb0-94de8078a7b5}.

2) Edit the new entry using the new GUID bcdedit generated in the copy step.

  a) Set the device and path for UEFI shell on my USB stick.

bcdedit /set {34e8383d-73a7-11e9-9cb0-94de8078a7b5} device partition=G:
bcdedit /set {34e8383d-73a7-11e9-9cb0-94de8078a7b5} path \EFI\SHELL\SHELLX64.efi

  b) Clean up some of the stuff that was copied from {bootmgr} (optional as far as I can tell, just makes things tidier in bcdedit)

Spoiler

bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} locale
bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} inherit
bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} default
bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} resumeobject
bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} displayorder
bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} toolsdisplayorder
bcdedit /deletevalue {34e8383d-73a7-11e9-9cb0-94de8078a7b5} timeout

 

3) Put the new EFI entry first in boot order. (optional)

Spoiler

bcdedit /set {fwbootmgr} displayorder {34e8383d-73a7-11e9-9cb0-94de8078a7b5} /addfirst

 

 

After completing the steps above, here is what "bcdedit /enum firmware" shows:

Spoiler

Firmware Boot Manager
---------------------
identifier              {fwbootmgr}
displayorder            {34e8383d-73a7-11e9-9cb0-94de8078a7b5}
                        {bootmgr}
                        {eace909f-3cb3-11e5-b87a-c28123693819}
timeout                 1

Windows Boot Manager
--------------------
identifier              {34e8383d-73a7-11e9-9cb0-94de8078a7b5}
device                  partition=G:
path                    \EFI\SHELL\SHELLX64.efi
description             UEFI Shell

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=S:
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {631bdfec-580c-11e8-9c1a-9d7903c42521}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 0

Firmware Application (101fffff)
-------------------------------
identifier              {eace909f-3cb3-11e5-b87a-c28123693819}
device                  partition=\Device\HarddiskVolume8
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager

 

I shutdown my computer and when I turned my computer back on it booted up into UEFI Shell. After exiting the shell my PC went on to boot Windows.

Here is the resulting dump using "bcfg boot dump -v" from that shell:

Spoiler

Option: 00. Variable: Boot0001   
  Desc    - UEFI Shell
  DevPath - HD(1,MBR,0x00020fa6,0x3f,0x64000)/\EFI\SHELL\SHELLX64.efi
  Optional- Y
  00000000: 57 49 4E 44 4F 57 53 00-01 00 00 00 88 00 00 00  *WINDOWS.........*
  00000010: 78 00 00 00 42 00 43 00-44 00 4F 00 42 00 4A 00  *x...B.C.D.O.B.J.*
  00000020: 45 00 43 00 54 00 3D 00-7B 00 33 00 34 00 65 00  *E.C.T.=.{.3.4.e.*
  00000030: 38 00 33 00 38 00 33 00-64 00 2D 00 37 00 33 00  *8.3.8.3.d.-.7.3.*
  00000040: 61 00 37 00 2D 00 31 00-31 00 65 00 39 00 2D 00  *a.7.-.1.1.e.9.-.*
  00000050: 39 00 63 00 62 00 30 00-2D 00 39 00 34 00 64 00  *9.c.b.0.-.9.4.d.*
  00000060: 65 00 38 00 30 00 37 00-38 00 61 00 37 00 62 00  *e.8.0.7.8.a.7.b.*
  00000070: 35 00 7D 00 00 00 30 00-01 00 00 00 10 00 00 00  *5.}...0.........*
  00000080: 04 00 00 00 7F FF 04 00-                         *........*
Option: 01. Variable: Boot0000   
  Desc    - Windows Boot Manager
  DevPath - HD(2,GPT,1aca364d-82dd-4f63-ac0e-aa9aa224e877,0xe1800,0x31800)/\EFI\Microsoft\Boot\bootmgfw.efi
  Optional- Y
  00000000: 57 49 4E 44 4F 57 53 00-01 00 00 00 88 00 00 00  *WINDOWS.........*
  00000010: 78 00 00 00 42 00 43 00-44 00 4F 00 42 00 4A 00  *x...B.C.D.O.B.J.*
  00000020: 45 00 43 00 54 00 3D 00-7B 00 39 00 64 00 65 00  *E.C.T.=.{.9.d.e.*
  00000030: 61 00 38 00 36 00 32 00-63 00 2D 00 35 00 63 00  *a.8.6.2.c.-.5.c.*
  00000040: 64 00 64 00 2D 00 34 00-65 00 37 00 30 00 2D 00  *d.d.-.4.e.7.0.-.*
  00000050: 61 00 63 00 63 00 31 00-2D 00 66 00 33 00 32 00  *a.c.c.1.-.f.3.2.*
  00000060: 62 00 33 00 34 00 34 00-64 00 34 00 37 00 39 00  *b.3.4.4.d.4.7.9.*
  00000070: 35 00 7D 00 00 00 30 00-01 00 00 00 10 00 00 00  *5.}...0.........*
  00000080: 04 00 00 00 7F FF 04 00-                         *........*
Option: 02. Variable: Boot0004   
  Desc    - Windows Boot Manager
  DevPath - HD(2,GPT,8429c978-b940-4995-82c2-1981df946ece,0x96800,0x32000)/\EFI\Microsoft\Boot\bootmgfw.efi
  Optional- N
 

 

You may notice that the shell shows as "Windows Boot Manager" in the bcdedit output. This I believe is because of the "WINDOWS" at the beginning of the option data that bcdedit added to the EFI Boot entry. I also believe this why bcdedit shows my Windows 8 installation as "Firmware Application" because it has no option data. I don't know how to remove this data using bcdedit nor do I know how the option data, that bcdedit adds, will affect other EFI applications.


There might be a way to create the EFI entry without copying the Windows entry but if there is I'm unable to find any documentation on how one would do so. If you use the create command then it just puts it in the BCD and I'm unaware of a way to tell it to create it in EFI instead, other than by doing the above.

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 4 years later...
 Share

×
×
  • Create New...