Dual Boot – Reboot to Windows

If you are configured your system with dual boot option and if you need reboot to an other boot entries directly from terminal then follow below steps.

Set Default boot

Setting default boot option will always boot into given boot entry

sudo gedit /etc/default/grub

GRUB_DEFAULT=0

0 is the top level entry in the boot menu and similarly 1 is the next boot entry and so on.

Then update the grub using below command

sudo update-grub

Reboot from Ubuntu to Windows directly from Terminal

Below command will list available boot menu entries and using this we can choose which OS should be booted on system start

grep menuentry /boot/grub/grub.cfg

Result:


0: menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-e959c450-8dcc-4434-9497-7b31250a37b2' {
1:        submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-e959c450-8dcc-4434-9497-7b31250a37b2' {
menuentry 'Ubuntu, with Linux 4.10.0-21-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-21-generic-advanced-e959c450-8dcc-4434-                 9497-7b31250a37b2' {
menuentry 'Ubuntu, with Linux 4.10.0-21-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-21-generic-init-upstart-e959c450-                 8dcc-4434-9497-7b31250a37b2' {
menuentry 'Ubuntu, with Linux 4.8.0-46-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.0-46-generic-recovery-                            e959c450-8dcc-4434-9497-7b31250a37b2' {
2: menuentry "Windows UEFI bootmgfw.efi" {
3: menuentry "Windows Boot UEFI loader" {
4: menuentry "EFI/ubuntu/fbx64.efi" {
5: menuentry "EFI/ubuntu/fwupx64.efi" {
6: menuentry "EFI/ubuntu/mmx64.efi" {
7: menuentry 'Windows Boot Manager (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-efi-286D-652F' {
8: menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {

You can see Windows is at the position 7, so reboot to windows will like below

sudo grub-reboot 7
sudo reboot

If you need to reboot to windows in single easy command then give an entry in bashrc file like below.

sudo gedit ~/.bashrc

Give entry in the last of the page and open new terminal to reflect the changes

echo "window          -> Switch to window"
alias window='echo '<sudo_password>' | sudo -S grub-reboot 7; sudo -S reboot'

Next time onwards typing window on terminal will reboot to Windows OS quickly.

Leave a Reply

Your email address will not be published. Required fields are marked *