I'm looking for a way to reboot into Windows from Ubuntu on a 10.10/Vista dual boot system. The specific use case is that I would like to be able to ssh into my running Ubuntu instance and issue a command that will initiate a reboot directly into Windows.
I found a promising blog post, but the script that it suggests isn't working:
#!/bin/bash
WINDOWS_ENTRY=`grep menuentry /boot/grub/grub.cfg | grep --line-number Windows`
MENU_NUMBER=$(( `echo $WINDOWS_ENTRY | sed -e "s/:.*//"` - 1 ))
sudo grub-reboot $MENU_NUMBER
sudo reboot
man grub-reboot
isn't much help, but it seems to be leading me in the right direction:
set the default boot entry for GRUB, for the next boot only
WINDOWS_ENTRY=`grep menuentry /boot/grub/grub.cfg | grep --line-number Windows`
MENU_NUMBER=$(( `echo $WINDOWS_ENTRY | sed -e "s/:.*//"` - 1 ))
echo $MENU_NUMBER
This returns the expected value, but on reboot the first menu entry is still highlighted. Any ideas why this isn't working or suggestions for other solutions?
You have to edit your grub first.
Search for the line GRUB_DEFAULT=0 and modify it to GRUB_DEFAULT=saved
Update your grub using the following command.
Now create a script file,
Then add these lines.
Make the script executable.
And now you can run this script from terminal to reboot into windows.
Or you can execute the following command in your terminal
Where X is the menuentry position of the OS you want to restart in from the GRUB menu.(starting with 0 as the first entry)
For Example:
sudo grub-reboot 5
There is a grub command just to do so, it is
grub-reboot
.It seems to only work when you have grub configured to start with the last saved entry. So if you have not already done so, modify
/etc/default/grub
and setthen update grub configuration file:
From now on, at each boot grub will start the last used entry.
Now, if you want to set in advance what should be the system to boot the next time, use
where
ENTRY
could be a number relative to a menu entry (numbered starting from 0), or an exact menu entry title, for exampleThis command can easily be made available as a launcher
but I don't know how it could be integrated into the system menu.
You can obtain the available menu entry title with
I think I have found an even nicer way for people who want to the same while locally at their pc without ssh.
A solution to reboot into a specific system choosen through a unity launcher was just posted on webupd8. See http://www.webupd8.org/2011/05/custom-unity-launcher-to-reboot-in.html
I know this is not exactly what the question is about but in case someone has a similar question later this might be helpful.
So for me the best was to create following script with
grub-reboot
commandI'm not sure if this will 100% also work in ubuntu, but I once made this work on a centos machine
basically you'll have to tell grub which id # from grub.conf it should run next. The id # can be found out by
so in my case this would e.g. output "4-1" as the fourth entry in my grub.conf contains the text "Windows". (Replace this with the actual entry name (also partially) you want to use. Then you can feed this to grub like:
and at the next reboot it should automatically boot the entry you've told it to.
this all can be put together in a script like the following:
the script will automatically determine which entry from your grub.conf corresponds to the text "Windows", will feed this to grub to tell what should be loaded on next boot and will reboot your pc.
for a gui you could e.g. add a shortcut icon to your desktop to achive this.
Simply edit
/boot/grub/grub.cfg
and change the default entry to point to the entry you want to boot. The value can either be the ordinal number of the entry (starting from zero for the first one) or you can place the full title of the entry you want in quotes.