Linux – Is it possible to select which system to boot before rebooting, on a multi-boot UEFI system

boot-managerlinuxmulti-bootuefiwindows

I'm wondering if there's a way to have a computer with UEFI and two different OSes installed (Windows 10 and Linux Mint 17.x in my case) where you don't have to wait for the system to shut down in order to select a different system to boot into.

To explain further:
The way multi-boot systems normally work is that a menu appears when the computer starts (from a uefi manager or boot loader etc) and you select an OS to boot. This menu can usually be configured to have a default, so that if left unattended it will "make a choice" on its own, or even to remember your last choice and re-use it until you make a different one (at least that was the case with legacy GRUB).

On my computer, Mint is the default and that works for most of the time. If I'm in Windows however and I want to reboot into Windows again, I have to wait for the GRUB menu to come up and select Windows, otherwise it will reboot into Mint. As shutting down can take a while (especially when installing updates) this means staying near the computer while otherwise I'd be able to step away.

Ideally, I'd like to be able to select an OS when I tell the computer to reboot.

Obviously this wouldn't be part of the standard "shut down" menu in either system, but I'm thinking it could possibly be made to happen with a script to run.
With GRUB, for example, it may be possible to have a script that changes its configuration file to set a certain system as default then starts a reboot, but that may take too long, would require root privileges and also only work from Mint.

Is there such a method, using any available boot manager (possibly rEFInd, for example) that would work from either OS without any special confirmation?

EDIT: rEFInd itself supports such a feature, apparently. Link The same page also suggests how to set the variable from Linux. Also, MSDN seems to have a method to set an EFI variable through C++ code, available in Windows 10. Link
So it seems that setting up a way to do this would be possible. I won't be able to attempt it until a few days from now, however.

Best Answer

Your question itself contains some possible answers. Another one is to manipulate the EFI's BootNext parameter. This sets a one-time boot to the specified target boot program. This can be done in Linux via the efibootmgr utility:

  1. Type efibootmgr (or efibootmgr -v to get more detail) as root or using sudo. This will display a list of your boot options.
  2. Identify the boot option you want to boot. For instance, to boot straight to Windows, you probably want the option entitled Windows Boot Manager. (Note, however, that these names are sometimes deceptive. You may need to experiment and figure out the details for your system.)
  3. Type efibootmgr -n #### as root or using sudo to tell the system to boot to Boot#### next, where #### is the number of the entry you want to boot.

I believe you can do something similar with EasyUEFI in Windows, but that's a GUI tool and so may not be useful for the scenario you describe. Perhaps bcdedit could do the trick, but I've not looked into it.

Related Question