# Tutorial - Adding new BCD entries on Lumia devices and ways to load them



## gus33000 (Feb 12, 2018)

Many have asked in the past how you're meant to add a new boot entry on Lumias, how to load them. After seeing what people were doing I decided to make this tutorial in order to help you boot whatever you want.
In this tutorial the term bootmgr refers to Windows boot manager (on lumias it's named bootarm.efi).

_This tutorial is not yet complete but already contains the basics to get started_

This tutorial is separated in different sections:


Adding a new boot entry on your device
Configuring your boot entry to load unsigned executables
Load an executable not meant to be loaded using bootmgr (Optional) (Will be detailed in the future)
Configure bootmgr to allow you to select which entry to boot

Adding a new boot entry on your device

Locating the Boot configuration database (BCD)

Put your phone in Mass Storage mode using WPInternals or developer menu or ffuloader if not already done and connect your phone to your PC.
The BCD file is located in (MainOS)/EFIESP/efi/Microsoft/Boot

It is recommended at this point that you make a backup of the EFIESP partition (or the BCD entry if you feel that's better suited for your needs) since any damage done to this file will prevent you from booting into mass storage mode on devices not supporting SBL MSC (ie: devices newer than Lumia x20s), and you'll need to reflash EFIESP in case something goes wrong.
In this folder, open a command prompt as administrator.

You can enumerate all entries in the BCD file by running the following command:


```
bcdedit /store BCD /enum ALL
```
Adding an entry

Depending on what you're planning to do, you may want to load one of 4 different types of things at boot on your device:


An EFI application (either using a Shim (described in the third section) or a bootmgr compatible application)
A Windows OS
A WIM image (will be detailed in the future)
A VHD/VHDX image (will be detailed in the future)

_1. Adding an entry for an EFI application_

Run the following command (and do not forget to replace the fields surrounded by <> to fit your needs):

```
bcdedit /store BCD /create /application bootapp /d "<the name for your entry>"
```

At this point BCDEdit will give you a GUID corresponding to the new entry you just created, note it down, you'll replace *<GUID>* in each following command with that GUID.
A couple notes about those commands:

*<the path where you placed the efi you want to load on the device partition>* should be replaced with the path where you did put the efi file on the phone with back slashes. It is important to note that it must only be the path without a partition location, you shouldn't have a driver letter, nor a mountpoint path. It must also begin with a backslash.

For example, these folders are mount points (you'll also note they have a little arrow):







*<path to the partition containing your efi>* should be replaced with the path pointing to the partition where your efi file is, in a similar way, if your partition is in a mountpoint, you must include the path to the mountpoint (example: for EFIESP in my case it would be H:/EFIESP, if it's in a driver letter, it should be just H: )


```
bcdedit /store BCD /set <GUID> path "<the path where you placed the efi you want to load on the device partition>"
bcdedit /store BCD /set <GUID> inherit {bootloadersettings}
bcdedit /store BCD /set  <GUID> device partition=<path to the partition containing your efi>
```

_2. Adding an entry for a Windows OS_

Run the following command (and do not forget to replace the fields surrounded by <> to fit your needs):

```
bcdedit /store BCD /create /application osloader /d "<the name for your entry>"
```

At this point BCDEdit will give you a GUID corresponding to the new entry you just created, note it down, you'll replace *<GUID>* in each following command with that GUID.

*<path to the partition containing your efi>* should be replaced with the path pointing to the partition where your efi file is, in a similar way, if your partition is in a mountpoint, you must include the path to the mountpoint (example: for EFIESP in my case it would be H:/EFIESP, if it's in a driver letter, it should be just H: )


```
bcdedit /store BCD /set <GUID> path \windows\system32\boot\winload.efi
bcdedit /store BCD /set <GUID> inherit {bootloadersettings}
bcdedit /store BCD /set  <GUID> device partition=<path to the partition containing your efi>
bcdedit /store BCD /set  <GUID> osdevice partition=<path to the partition containing your efi>
bcdedit /store BCD /set  <GUID> locale <your language code, example: en-US>
bcdedit /store BCD /set  <GUID> bootdebug No
bcdedit /store BCD /set  <GUID> systemroot \windows
bcdedit /store BCD /set  <GUID> bootmenupolicy Standard
bcdedit /store BCD /set  <GUID> detecthal Yes
bcdedit /store BCD /set  <GUID> winpe No
bcdedit /store BCD /set  <GUID> ems No
```

Configuring your boot entry to load unsigned executables

In case your boot entry isn't trusted by the device, you may want to allow loading an unsigned application, in order to do this you have to set two elements on your entry:


```
bcdedit /store BCD /set <GUID> testsigning on
bcdedit /store BCD /set <GUID> nointegritychecks on
```

Configure bootmgr to allow you to select which entry to boot

This case will be different for some people, there's two ways to load entries easily on lumias, and the easiest one actually won't work with all lumias devices.
If your device has a camera button, you can actually follow the first way, and the second way, if your device has no camera button, you're forced to use the second way.

_First way_

Run the following commands on your device:


```
bcdedit /store BCD /set {bootmgr} displaybootmenu on
bcdedit /store BCD /set {bootmgr} timeout 10
bcdedit /store BCD /deletevalue {bootmgr} customactions
bcdedit /store BCD /deletevalue {bootmgr} custom:54000001
bcdedit /store BCD /deletevalue {bootmgr} custom:54000002
bcdedit /store BCD /displayorder {default} {0ff5f24a-3785-4aeb-b8fe-4226215b88c4} {bd8951c4-eabd-4c6f-aafb-4ddb4eb0469b} <other entries you may want to be displayed>
```

This will make your phone display the boot selection menu, you can select which entry you want with the volume buttons, and load the entry with the camera button.

_Second way_

If your phone doesn't have a camera button, you sadly have to use this way. But you also can use it with phones having a camera button, it's up to you.
To load your entry, you'll need to modify either one of two elements. By default those two elements are set to the reset phone app and the ffu loader app, you'll loose access to them if you modify the entries.

custom:54000001  is for volume up
custom:54000002  is for volume down

To reconfigure one for your entry run:


```
bcdedit /store BCD /set {bootmgr} custom:5400000<id> <GUID>
```

Then when you'll press the key you did set you'll boot to your entry.


----------



## ahmadus (Feb 12, 2018)

great !


----------



## augustinionut (Feb 12, 2018)

After add a new boot entry on your phone make a efiesp backup


----------

