1

I want to setup my desktop with dualboot such that i can switch between the two OSes from remote. Specifically, Windows 10 and Fedora 38.

I usually boot it remotely using Wake on LAN, so it would be great if that could be a viable path to choose which system to boot into

Some friends suggested making scripts to edit the boot order from the current OS and then rebooting, but nobody was sure how to do it reliably or if this would be easy to break.

other questions I've seen here on superuser suggest editing the boot order or using Linux specific software

Edit: I have not setup the dualboot yet, I wanted to understand how this problem could be solved beforehand

2

2 Answers 2

4

If you are using UEFI firmware, which supports multiple bootloaders side-by-side (e.g. GRUB and Windows Boot Manager), change the BootNext EFI variable to select one of them and reboot.

(That is, wake the machine; let it boot into the default OS; set BootNext; reboot into the other OS.)

Linux Windows
efibootmgr bcdedit /enum firmware
efibootmgr --bootnext NUM bcdedit /set {fwbootmgr} bootsequence GUID
efibootmgr --bootorder NUM… bcdedit /set {fwbootmgr} displayorder GUID…
reboot, systemctl reboot shutdown /r /t 0

For example, if GRUB is the default entry (and boots into Linux) but you want to select Windows Boot Manager just once, you can do:

# efibootmgr
 BootCurrent: 0001
 BootOrder: 0001,0000
 Boot0000* Windows Boot Manager
 Boot0001* Ubuntu
 Boot001F  USB HDD
# efibootmgr --bootnext 0000
# reboot

From Windows, the same can be done either through the graphical "Shift+Reboot" menu, or using bcdedit to set its 'bootsequence' parameter (use the GUID from the 'identifier' field), both of which are translated to EFI BootNext.

This is usually as reliable as the F8/F11 firmware boot menu, so make sure that works first.


On the other hand, if you're using BIOS mode (and probably loading both Linux and Windows from the GRUB menu), something similar is available through GRUB's own configuration – in a typical grub.cfg, the equivalent to EFI BootNext would be $next_entry, which could be set using:

# grub-editenv set next_entry ENTRY_ID

This is annoying to do from Windows, so it's easier to keep Linux as the default option.

Similarly, Windows Boot Manager also has a 'bootsequence' parameter on {bootmgr} (not to be confused with {fwbootmgr} which represents EFI parameters), so if you have a GRUB entry added to Windows Boot Manager you can have Windows as the default OS and switch to Linux on demand. (I have not tested this.)

3
  • 1
    There're also some nice little utility (e.g. this) on github which makes changing UEFI BootNext on Windows easier btw.
    – Tom Yan
    Commented May 23, 2023 at 16:12
  • I have to admit i hoped there would be some approach that felt more "safe" than editing the boot order at each startup, but this seems to be the best way, and your explanation was very thorough!
    – Udinanon
    Commented Jun 26, 2023 at 14:47
  • @Udinanon: That is what's described here. When changing BootNext you're not editing the regular boot order – you're telling the firmware to ignore the boot order and boot a different OS just this once. Isn't that exactly what you're asking for? Commented Jun 26, 2023 at 15:22
0

If you boot through grub, then create two versions of the grub.cfg file.

  • Save a copy of /boot/grub/grub.cfg with its current boot order, e.g. as grub.fed if Fedora is first.
  • Modify grub by entering sudo gedit /etc/default/grub in Terminal to switch the default OS to the opposite, e.g., from Fedora to Windows.
  • Run update-grub to create a new grub.cfg.
  • Save a copy of /boot/grub/grub.cfg with the new boot order, e.g. as grub.win

Now, make a script to copy the appropriate file over grub.cfg, so that the next time the machine reboots, after the set delay (perhaps 10 seconds), the selected OS starts.

Another option is to rename the files in the EFI/boot folder.

Of course, logging in remotely to the rebooted machine is another issue, if a password is needed.

3
  • Your answer is kinda "dangerous" as it assumes that the user can replace /boot/grub/grub.cfg with grub.fed in Windows, which may not be the case.
    – Tom Yan
    Commented May 23, 2023 at 16:17
  • @TomYan, yes, that is left as an exercise for the OP. Another option, equally dangerous, has been added. Commented May 23, 2023 at 16:29
  • For the record, when I said can('t) I am not referring to the OP's "ability", but the fact that /boot/ might not necessarily be mounted with a filesystem that is supported in Windows at all.
    – Tom Yan
    Commented May 23, 2023 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .