Powered By

Powered by Blogger

Minggu, 03 Oktober 2010

How To Reboot In Windows From Ubuntu (GRUB 2)

If you're dual-boot Ubuntu and Windows, you can use a simple command (or create a menu shortcut for it) to easily restart in Windows from Ubuntu. This should actually work with any Grub entry, not just Windows (so if you using multiple Linux distributions, it will work with that too).

Note: this will only work with GRUB 2.

This command will not change the GRUB menu entries order. When GRUB starts, the first entry in the menu list is highlighted - this command will highlight the menu entry you set and will boot it if you don't select a different option (so the GRUB menu will still be displayed if you've set a GRUB timeout higher than 0).

1. Edit /etc/default/grub:

sudo gedit /etc/default/grub

and modify the "GRUB_DEFAULT=0" value (it should be on line 4) from "0" to "saved" (without the quotes) so that it looks like this:

Then save the file.

2. Update GRUB:
sudo update-grub

3. Now to reboot Ubuntu in Windows or some other OS, run the following command:
sudo grub-reboot X

where X is the menuentry position (starting with 0 as the first entry) of the OS you want to restart in from the GRUB menu. So if Windows is the 4th option in the GRUB menu, you would run "sudo grub-reboot 3". You can also use the exact menu entry instead of the menuentry position (like "Windows 7 (on /dev/sda1)") but entering just a number should be easier to remember. The grub-reboot will set the default boot entry for the next boot only.

Then simply restart your computer and it should boot in Windows or whatever GRUB menuentry choice you've entered for the above command.

4. (optional) For easy access, you can make a script which automatically makes your computer restart in predefined OS:
gksu grub-reboot X
gksu reboot

Again change "X" for the GRUB menuentry number you want to boot in (counting from 0) and make a shortcut for this script on your panel for example.

Tidak ada komentar:

Posting Komentar