1

I have the following disks:

/dev/sda 
  /dev/sda1 EFI partition
  /dev/sda2 Windows
/dev/sdb
  /dev/sdb1 EFI partition
  /dev/sdb2 Linux                    <-- currently mounted as /

and I am currently using Linux, so /dev/sdb2 is currently mounted as /.

My BIOS is set up to boot by default on second HDD, thus booting on Linux.

Question: from Linux command-line, how to reboot to Windows, i.e. /dev/sda2? (the bootloader is in /dev/sda1, more precisely in /EFI/Boot/bootx64.efi)

Without having to do something like F12 on computer startup to trigger a boot menu, and without choosing an option in a Grub / boot menu.
TL;DR: Is there a way to reboot to /dev/sda2 with a single command line command?

Basj
  • 2,519
  • 1
  • @Panki No, I don't want to modify GRUB settings, but rather reboot on a specific device once, without modifying GRUB settings. – Basj Oct 27 '21 at 13:40
  • GRUB is your bootloader. How are you gonna boot a different partition without telling your bootloader what you want? – Panki Oct 27 '21 at 13:49
  • @Panki Yes but I don't want to make a permanent change to GRUB, I only want to boot on another partition for next boot. Also (out of curiosity), is it possible for Linux, to "jump" to the instruction at /dev/sda1's /EFI/Boot/bootx64.efi directly from command line, could we imagine to avoid having to reboot, and skip the BIOS sequence, and directly execute code /dev/sda1's /EFI/Boot/bootx64.efi? – Basj Oct 27 '21 at 14:11
  • See this: https://askubuntu.com/questions/574295/how-can-i-get-grub2-to-boot-a-different-option-only-on-the-next-boot and you can add a Windows entry to 40_custom to configfile or chainloader type entry to /EFI/Boot/bootx64.efi and/or /efi/Microsoft/Boot/bootmgfw.efi . You can add Windows or fallback type entry: https://askubuntu.com/questions/344125/how-to-add-a-grub2-menu-entry-for-booting-installed-ubuntu-on-a-usb-drive/344359#344359 – oldfred Oct 27 '21 at 15:03
  • Thanks, but this would make permanent changes on GRUB @oldfred? Is there absolutely no way to just jump to the bootloader of a specific device at a given time, without having to modify GRUB settings and go by the BIOS boot sequence, etc.? – Basj Oct 27 '21 at 15:09
  • This shows one change to grub. https://wiki.debian.org/GrubReboot But first link above has first comment in accepted answer on command line to to do it without change. did you review that? – oldfred Oct 27 '21 at 15:14

2 Answers2

3

First, run sudo efibootmgr -v to display your current UEFI boot variables. The boot entries will be named BootXXXX where XXXX=four-digit number (might be hexadecimal).

If there is a boot entry whose second column says "Windows Boot Manager", then that is the boot entry for Windows. It should look similar to this:

BootXXXX* Windows Boot Manager  HD(2,GPT,12345678-90ab-cdef-0123-456789abcdef,0x109000,0x32000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{ <UTF-16 representation of an UUID here>

Here, the 12345678-90ab-cdef-0123-456789abcdef will be the PARTUUID of the ESP partition from where the Windows boot manager \EFI\Microsoft\Boot\bootmgfw.efi will be located on. In your case, it should be the PARTUUID of your /dev/sda1 disk. Use lsblk -o +PARTUUID to view the PARTUUIDs of your disk partitions.

Once you know the XXXX number of your Windows boot entry, you can run:

sudo efibootmgr --bootnext XXXX

This should make the system boot (once only) using the specified boot entry, i.e. to Windows. Once you tell Windows to shut down or reboot, the next boot should automatically start Linux again.

After using the sudo efibootmgr --bootnext command, the system is primed to boot into Windows, and you can use any of the normal commands to reboot the system.

If you want to do it with a single command, you can make a simple script:

#!/bin/sh
sudo efibootmgr --bootnext XXXX
sudo reboot
telcoM
  • 96,466
0

systemctl reboot --firmware-setup

This will reboot into the BIOS setup utility.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
  • Thanks, but the question is how to reboot and boot on /dev/sda, and not into BIOS setup utility. – Basj Nov 26 '22 at 15:47