2.3 KiB
2.3 KiB
Setup Boot to Windows
In a dual boot setup where the default boot is Linux, you may want to be able to directly reboot into Windows without having to manually interrupt your bootloader (like GRUB) or your UEFI boot priority.
From Linux
efibootmgrwill be required, so install that from your distro's package manager.- Create the file
/usr/local/bin/boot-windowsand put the following script into it: (source: Bazzite windows-boot script)
#!/bin/bash
# Look up the boot number for Windows in the EFI records
boot_number=$(echo $(efibootmgr) | grep -Po "(?<=Boot)\S{4}(?=( |\* )Windows)" | head -n1)
# Check that Windows EFI entry was found
if [ -z "$boot_number" ]; then
echo "Cannot find Windows boot in EFI, exiting"
exit 1
fi
# Set the next boot to be Windows and reboot the machine
sudo efibootmgr -n "${boot_number}" && reboot
- Run
sudo chmod +x /usr/local/bin/boot-windowsto make the script executable. - To let
sudo efibootmgrrun without needing a password add the file/etc/sudoers.d/efibootmgr-configwith the following text: (source: Bazzite)
%wheel ALL=(root) NOPASSWDL /usr/sbin/efibootmgr
- Optionally create a button in your desktop environment that will run that script when clicked.
Note: if running this script does work but you have to manually trigger a reboot, you may need to edit the last part of the last line to be sudo reboot instead of just reboot
From Windows
If you want to be able to reboot back into windows from windows without changing the boot order you will need to do the below:
- Navigate to a Folder like your Documents folder or somewhere else out of the way.
- Ensure you have enabled viewing file extensions, and create a new "Text Document" but rename it to
reboot-to-windows.bat - Right-click on the file and Open in Notepad (or your text editor of choice) and add the following lines:
bcdedit /set {fwbootmgr} bootsequence {bootmgr}
shutdown /r /t 0
- Save and close the file, then right-click on it and
More Options -> Create a Shortcutto it. - Right-click the shortcut and click Properties. Then click
Advanced...and check "Run as administrator" - Click OK and OK to exit out of those menus.
- Rename that shortcut and move it as you please. When you run that shortcut you should reboot back into windows.