Reboot to windows
published on Friday, October 26, 2018
A beginner treat from the tips and tricks box today:
For dual-booters like me, it is sometimes very convenient to boot from linux directly into windows without having to watch the boot menu. If you're using grub, this is possible with the the grub-reboot command. It can be called with the name of the windows boot entry as follows:
The exact line will of course differ on most systems and can be read off from
Alternatively, grub-reboot can be called with the index of the boot entry, but I prefer using the name for more clarity and stability.
(BTW: If you don't use grub but rely on an efi boot manager instead, there are also tools to set efi variables for the next reboot, see e.g. efibootmgr -n.)
Wrapping it up
For convenience, I recommend putting this in /usr/local/bin:
To make it even more convenient, add the following alias in your .bashrc:
and enable passwordless execution for this script by typing sudo visudo and appending the following line:
Don't forget to chown root and chmod 755 the towin script!
Wake on LAN
If you like this, you may also be interested in setting up your computer for Wake on LAN, see WOL dual-boot. I recommend configuring grub to boot linux by default, also set a short wait time, and don't let it save your last choice:
Once linux is up you can always quickly towin back to windows if you've missed the boot menu. Even remotely booting to windows can be achieved by waking the PC to boot linux first and then executing towin via SSH.
Regenerate the grub.cfg with:
System independent script
If you want to maintain the same script across different machines, the following may just work in many cases: