Remote Boot Selection with Dual Boot Computer


You can select the next OS to boot on headless and remote dual boot systems by setting your system up as described below.

Install Windows first.
Then install Linux.
If you install on the same disk, this will result in grub as your boot loader.
If you install on separate disks, change the boot order with your BIOS to boot grub first.
I prefer the default OS to be Windows.
Change the boot order in linux:
cd /etc/grub.d
sudo mv 30_os-prober 03_os-prober
sudo update-grub
sudo reboot

I have linux installed on a separate disk and it is formatted EXT4.
To access this disk when booted in Windows, use WSL2
https://learn.microsoft.com/en-us/windows/wsl/install
After rebooting and completing the installation, at the wsl prompt
sudo apt install grub-common

You can find the correct disk DeviceID with (administrator PowerShell):
wmic diskdrive list brief

Check the correct partition with Disk Management.
Note that partitions start at 1.

Then mount the disk in an administrator PowerShell:
wsl --mount \\.\PHYSICALDRIVE0 --partition 2

to change the next boot OS in WSL shell:
cd /mnt/wsl/PHYSICALDRIVE0p2/
sudo grub-editenv boot/grub/grubenv set next_entry=1

note that grub entries start at 0.