Consider the following dual-boot setup:

  • Grub is installed to /dev/sda
  • /dev/sda1 is mounted as /boot
  • /dev/sda6 is mounted as /
  • Windows 10 is installed to /dev/sdb2

As it stands now, Grub selects Ubuntu by default when it boots and I can remotely login via SSH. It is also possible to select Windows when Grub starts and I can remotely login via RDP.

The problem is that I have no way of selecting which OS to boot when I am not physically present.

This question describes a method for having Grub automatically boot the last selected operating system. However, this will not work. If I select Windows, I have no way to remotely restart the PC and boot Ubuntu.

Is there a way to remotely control which OS boots?

  • @Takkat from the Windows side though? (Can I be running Windows and have some sort of program or script instruct Grub to boot Ubuntu?) – Nathan Osman Aug 14 '15 at 18:44
  • @Takkat oh, I see what you're saying... that might work. – Nathan Osman Aug 14 '15 at 18:46

We can reboot to a given Grub menu boot entry using grub-reboot. This can also be done from a remote session e.g. via SSH.

To boot into another OS choose the position it is represented in the Grub menu starting from 0:

sudo grub-reboot <num>

enter image description here

In this case my Windows is on position 4. So when issueing

sudo grub-reboot 4 && sudo reboot

The machine will reboot to Windows after the timeout we defined in the Grub settings.

After rebooting from Windows the machine will boot into the default OS. This can be defined with

sudo grub-set-default <num>

To make this work we may have to define GRUB_DEFAULT=saved in our /etc/default/grub but on my system it also worked with the default settings.

Sadly rebooting Windows from Windows can not be done by this.


Another idea thanks to takkat's answer:

  1. Default boot is Ubuntu
  2. grub-reboot N where N is the Windows boot entry
  3. Rebooting Windows will bring you back to default boot: Ubuntu.

Disadvantage: to reboot Windows you have to reboot twice: Reboot Windows, let Ubuntu boot and grub-reboot N again! :-(

  • More ideas please. :) – A.B. Aug 15 '15 at 15:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.