One click shutdown Ubuntu and load into alternative bootup
I have a dual boot system with Ubuntu 11.04 and Windows 7.
My GRUB bootloader defaults to Ubuntu. I mainly use Ubuntu, but I occasionally need to bootup Windows to do a few things.
If I need to do something in Windows I can "shutdown" Ubuntu and select Windows 7 in the bootloader. However, it would be more efficient if I could do this in one click from Ubuntu.
- Is it possible to press a key in Ubuntu which means "Shut down, and then boot into Windows"? (or for that matter Shut down and boot into any non-default bootup)
In case you know the entry number for your Windows installation (start counting with 0
for first position) in the grub menu you can reboot into Windows (assuming to be 3rd on the list) by this command:
grub-reboot 2
Alternatively you can also use the textual entry used:
grub-reboot '<type entry here>'
This command can also be put in a launcher for "single-click" usage.
To make this procedure work we need the entry GRUB_DEFAULT=saved
in /etc/default/grub
.
@Takkat has answered the question, but I thought I'd describe a few more details in case it might help others.
- Boot menus count from zero. I have five elements in my boot menu. The fifth element is Windows, thus, to reboot to Windows, I had to issue the command
grub-reboot 4
(i.e., not 5). UPDATE: see comments below about this possibly changing. - In order to edit
/etc/default/grub
I issuedsudo vim /etc/default/grub
. - To make the procedure work, I had to modify the existing value of
GRUB_DEFAULT=0
toGRUB_DEFAULT=saved
and then runsudo update-grub
.
I then created a script based on the webupd8 example:
I called it winboot
and put in in ~/bin
#!/bin/bash
gksu grub-reboot 4
gksu reboot