How to directly reboot from Linux to Windows
GNU/Linux is (for me) the best operating system for programming, but when it comes to gaming Windows still has the better…
So I’ve always kept a dual-boot on my main PC because I like to play after a day of studying. I’ve often had to reboot my PC and get stuck at the desk breathlessly waiting for the GRUB screen to come up so that I don’t end up back on GNU/Linux and have to reboot a second time, hoping that will be the last.
That’s why I’ve been looking around for a way to solve this “problem”…
I found the solution! A simple ALIAS for bash, zsh or any other shell that supports them and here’s how I did it…
1 — The new ALIAS
- Open
~/.bashrc
or~/.zshrc
- Add
alias wreboot="sudo grub-reboot X && reboot"
replacing theX
with the position of the Windows entry in the GRUB list (starting from zero) - Save file
2 — Update the GRUB
- Open
/etc/default/grub
- Set the variable
GRUB_DEFAULT
assaved
. - Save file
- Execute
sudo update-grub
(on Ubuntu)
Orsudo grub-mkconfig -o /boot/grub/grub.cfg
(on ArchLinux)
3 — Get rid of SUDO password
Replacing *USER*
with your username and *PATH*
with the path getted using which grub-reboot
(ex: /usr/bin/grub-reboot
):
- Open
/etc/sudoers.d/*USER*
withsudoedit
- Add
*USER* ALL=(ALL) ALL
And*USER* ALL=(root) NOPASSWD:*PATH*
- Save file
That’s all folks!
Now when you run wreboot
in your terminal the PC will automatically reboot into Windows.