Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
If you copy the windows grub boot line to the top of the list in the grub menu then on each boot windows will be the default load.. if you're in ubuntu and ssh into it then.sudo reboot now should reboot the machine into the first item in the grub list. – karthick87 Dec 19 '10 at 21:05
Sure, but I rarely boot into that Windows partition. I don't want to make it the default entry. – andrewsomething Dec 19 '10 at 21:33

2 Answers

up vote 14 down vote accepted
  • You have to edit your grub first.

    sudo gedit /etc/default/grub

  • Search for the line GRUB_DEFAULT=0 and modify it to GRUB_DEFAULT=saved alt text

  • Update your grub using the following command.

    sudo update-grub

  • Now create a file and add these lines,

    !/bin/bash
    WINDOWS_ENTRY=`grep menuentry /boot/grub/grub.cfg  | grep --line-number Windows`
    MENU_NUMBER=$(( `echo $WINDOWS_ENTRY | sed -e "s/:.*//"` - 1 ))
    gksu grub-reboot $MENU_NUMBER
    gksu reboot
    
  • 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

    sudo grub-reboot X

  • 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:

  • If this is your grub menu and if you want to boot into windows you should give the value of X as 5.
  • sudo grub-reboot 5

    alt text

  • You can also create a launcher for the above command,so that double clicking the launcher will reboot into windows.
share|improve this answer
This is a great answer! – andrewsomething Dec 19 '10 at 23:12
I can get it to work once. After that you have to enter passwords. – hashky Jan 2 '11 at 19:37
3  
How did you get grub to look like that? – Mandy May 14 '11 at 1:03
follow up the question above? how can you get grub looking so perty? – Diego Aug 8 '12 at 21:30

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.