Skip to content

Instantly share code, notes, and snippets.

@BoQsc
Last active August 10, 2019 17:00
Show Gist options
  • Save BoQsc/e318649c7c917fcc467f71354a87f917 to your computer and use it in GitHub Desktop.
Save BoQsc/e318649c7c917fcc467f71354a87f917 to your computer and use it in GitHub Desktop.
Command to schedule next GRUB2 boot into Windows or BIOS/UEFI (Tested on Ubuntu only)

Find menu entry

Note: There is no Windows operating system entry, since GRUB_DISABLE_OS_PROBER=true variable existed in the file/etc/default/grub

vaidas@vaidas-SATELLITE-L855:~$ awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg 
Ubuntu
Ubuntu, with Linux 5.2.0-8-generic
Ubuntu, with Linux 5.2.0-8-generic (recovery mode)
Ubuntu, with Linux 5.0.0-20-generic
Ubuntu, with Linux 5.0.0-20-generic (recovery mode)
System setup
vaidas@vaidas-S

To boot into BIOS/UEFI:

sudo grub-reboot "System setup"

To boot into Windows

you have to make sure that GRUB_DISABLE_OS_PROBER=true configuration line does not exist and is commented in the file: /etc/default/grub

Find menu Windows entries

awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg 
Ubuntu
Ubuntu, with Linux 5.2.0-8-generic
Ubuntu, with Linux 5.2.0-8-generic (recovery mode)
Ubuntu, with Linux 5.0.0-20-generic
Ubuntu, with Linux 5.0.0-20-generic (recovery mode)
Windows Boot Manager (on /dev/sda2)
System setup

Here is booting to Windows Command

sudo grub-reboot "Windows Boot Manager (on /dev/sda2)"


Smoother faster transition without Grub timeout

If you want smoother/faster transition from GRUB2 to Ubuntu/Windows you might find yourself modifying GRUB_TIMEOUT and setting it to 0 (GRUB_TIMEOUT=0) in the file/etc/default/grub and

  • To edit the file, here is the command: sudo gedit /etc/default/grub

For it all to work, also it is needed to find and edit Timeout code line in a file /etc/grub.d/30_os-prober

  • To edit the file, here is the command: sudo gedit /etc/grub.d/30_os-prober

Before edit:

set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
  set timeout=10
fi

After edit

set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
  set timeout=0
fi

Source: https://askubuntu.com/a/157940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment