Reboot to Windows on a UEFI system
A watched PC never boots. proverb
I am the sort of person who needs to boil a kettle of water three or four times. I will turn it on, walk away, forget it until it’s cold, and repeat.
I dual boot my desktop computer between Linux and Windows (to play Overwatch). By default, the computer boots into Linux. To boot into windows I need to catch it while it’s displaying the boot menu which has a 3 second timeout. I am terrible at this.
Years ago, I blogged about changing the grub default with a script to reboot into windows. But I’m now using systemd-boot, a UEFI boot manager.
Fortunately, UEFI itself provides a solution. There’s a BootNext
variable, which allows choosing a one-time boot entry.
First I list my boot entries using efibootmgr
.
$ sudo efibootmgr
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0000,0002,0003,0004
Boot0000* Windows Boot Manager
Boot0001* Linux Boot Manager
Boot0002* Samsung SSD 850 EVO 500GB
Boot0003* SanDisk SDSSDHP256G
Boot0004* SAMSUNG SSD 830 Series
Seeing that Windows is Boot0000
I can make the following reboot-windows
script
Easy! Running reboot-windows
will boot me into Windows, bypassing the
systemd-boot
bootloader entirely. Rebooting from windows will take me back to
Linux (through systemd-boot
again).