EFI Dualboot – Changing EFI NVRAM boot order from Windows

So I was having some trouble making grub work on a machine that was running in EFI, but found the nice easy command efibootmgr for Linux to help me manage the boot order.
“efibootmgr” without any switches to show me the current possible options and then “efibootmgr -n 0000” to tell it next reboot I want to boot windows for one time only. (Of course that number will vary depending on what you’ve got install and in what order, and which you actually want to boot)
So now I had a nice easy way to boot the machine into Windows if it was starting Linux, but could I work out how to change the EFI boot order from Windows no not as quickly as I would have liked, but I am there now and it’s one of those things I didn’t find anywhere on the Internet when I needed help so am blogging hoping the search engines will help other people with the same issue.
First of all I tried bootmgr, that was a waste of time, so moved onto bcdedit.
bcdedit /bootsequence “Sets the one-time boot sequence for the boot manager.” sounded liked a really good idea, but what this does is it tells the windows boot manager to try and load the other EFI file, and Windows complains about this. So that wasn’t the soultion….
I eventually found a BCDedit refrence document and found some intreasting stuff towards the back pointing me in the direction of “bcdedit /set” being used to set various options one of the listed well know identidiers was {fwbootmgr}
This lead me to to try:
“bcdedit /? types” and I got this list:
BOOTAPP Boot applications. These types also apply to the boot manager,
memory diagnostic application, Windows OS loader, and the resume
application.
BOOTMGR Boot manager.
BOOTSECTOR Boot sector application.
CUSTOMTYPES Custom types.
DEVOBJECT Device object additional options.
FWBOOTMGR Firmware boot manager
MEMDIAG Memory diagnostic application
NTLDR OS loader that shipped with earlier Windows OS
OSLOADER Windows Vista OS loader
RESUME Resume application
So next it was oh what types can we have for {fwbootmgr}
“bcdedit /? types fwbootmgr”
FIRMWARE BOOT MANAGER
The following types apply only to entries for the firmware boot manager. For
information about data formats for these types, run “bcdedit /? FORMATS”.
Boot
====
BOOTSEQUENCE (list) Defines the one-time boot sequence.
DEFAULT (id) Defines the default boot entry.
TIMEOUT (integer) Defines the boot manager time to wait, in seconds.
Display
=======
DISPLAYORDER (list) Defines the boot manager display order list.
I was quite happy to see BOOTSEQUENCE in that list so I ran a “bcdedit /enum firmware” and got the GUID for the Linux install I wanted to run and then the command that did want I wanted was:
“bcdedit /set {fwbootmgr} BOOTSEQUENCE {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}” where {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} was the GUID value from the linux EFI entry I wanted it to try and load.
A quick “shutdown -r” and BINGO the machine could now be rebooted into Linux once from Windows without having to get into the BIOS to change the boot order. I prefer this soultion over grub as Windows now gets pure Windows and grub doesn’t need to worry about Windows.
Of course if you want to make your change last you’ve got the “bcdedit /set {fwbootmgr} DISPLAYORDER {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}” option availble to you. Then if you’re changing the display order you do probably want to put more that one GUID in the list. (Lists are seperated by spaces in this case)
Also remeber being failry low level operations bcdedit to be any use quite rightly requires runnign from an elevated command prompt.
I hope this will make someone elses life easier!
 
 
 

Join the Conversation

4 Comments

  1. Hi Mike,
    i got to this post looking for a way to add a linux efi boot loader to the windows boot manager (8.1)…
    As it looks like You got Your feet wet with it, i hope You can clarify some doubts i have – just got a new pc with uefi, big jump from BIOS to this firmware stuff.
    As far i understand, the default windows loading process, overly simplified goes…
    1. {fwbootmgr} is the firmware boot manager installed on the main board…
    2. …it loads the windows boot manager {bootmgr}…
    3. …and that one loads the {current} windows boot loader
    so far so good.
    I found entries of “Firmware applications” using “bcedit /enum all”, and those seem to follow the UEFI standard of external devices, looking for a “fallaback” entry (\EFI\BOOT\BOOTx64.EFI), hence no need to set the path property on those.
    Now, i tried various setups (all using bcdedit), like “/application osloader”, “/inherit bootmgr”, “/inherit fwbootmgr”, adding them in the displayorder of {bootmgr}.
    They show up in the boot manager, but they fail to load once i select to boot them. The screen i get seems like a windows recovery menu (text-mode, b/w).
    That makes me wonder…is the {bootmgr} of windows capable of loading an arbitrary .efi file (for now i am trying efilinux.efi), or it is only useful for windows OS-es? Any idea on this? What kind of an entry did You create for grub? Could You share the output of Your setup, eg “bcdedit /enum”?
    Cheers!

    1. We couldn’t make the Windows part of the {bootmgr} then daisy chain into a grub, even if we did think that grub should be working, but we could use Windows to tell the system UEFI stuff to boot a diffrent entry from the {fwbootmgr}. I’ll get in front on the machine I did all this on and get you some more details later today.

  2. This is perfect for dual booting Windows and a Linux distro on a touchscreen tablet which has no way of interacting with a grub (or any other) bootloader. Not the quickest way to boot into which OS you need, but it gets the job done and doesn’t require hooking up a keyboard, just create a shortcut and we’re away. Thanks.

  3. Just wanted to say thanks! I’m primarily a Linux user, but I do use windows for gaming. My PC is set to boot Linux by default and I have a shortcut linked to a script I wrote to use efibootmgr to set the nextboot flag to windows and then reboot when I want to get into windows.
    I was trying to figure a way to do the same thing in windows for the times that I need to reboot from windows and back to windows easily. I was on the right track with bcdedit but didn’t quite figure it out and like you I couldn’t find info on this anywhere until I pretty much by accident stumbled upon your post. I ended up whipping up a little batch file, creating a shortcut to it and pinning it to the start menu with a windows icon I found online and then setting it to run as admin. Now when I need to reboot back to windows I just use it instead of the normal reboot option which sends me back to Linux.
    http://i.imgur.com/XdgOqr8.jpg
    [Contents of bat file for anyone interested]
    @ECHO off
    ECHO Setting UEFI to boot Windows once.
    start /B bcdedit /set {fwbootmgr} BOOTSEQUENCE {bootmgr}
    ping -n 2 127.0.0.1 > nul
    ECHO Rebooting Windows…
    start /B shutdown /t 1 /r

Leave a comment

Your email address will not be published. Required fields are marked *