Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have both Windows 7 and Ubuntu installed on a shared machine. Because a lot of the non-developers use Windows, I'd like to change the boot order to make it easier for them.

Currently the boot order looks like the following:

  • Ubuntu 11.10 kernelgeneric *86
  • Ubuntu 11.10 kernelgeneric *86 (safe boot)
  • Memory test
  • Memory test
  • Windows 7 on /dev/sda6

How do I change the default order so that Windows 7 is at the top of the list?

  • Windows 7 on /dev/sda6
  • Ubuntu 11.10 kernelgeneric *86
  • Ubuntu 11.10 kernelgeneric *86 (safe boot)
  • Memory test
  • Memory test
share|improve this question
2  
Similar Q&A: askubuntu.com/questions/52963/… –  fossfreedom May 20 '12 at 18:58
    
Did you do a 'sudo update-grub' after changing the grub file? –  Tinellus Jun 27 '12 at 12:49
    
yes I think I may have forgotten to do that, thank you! I will try and update with the results. –  jeffery_the_wind Jun 27 '12 at 12:51
add comment

5 Answers

up vote 123 down vote accepted

You can use an easy-to-use the GUI application called Grub Customizer to make your life a little bit easier. As the name suggests, you can do much more than just reordering GRUB menu entries with it.

You can install it by:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

(See Ask Ubuntu question Are PPA's safe to add to my system and what are some “red flags” to watch out for?.)

There is an How-To Geek article about it, How to Configure the Linux GRUB 2 Boot Menu the Easy Way. Take a look at it if you're interested. Also, there is a solved thread on the Ubuntu Forums, Change boot order in GRUB 2 that mentions this tool.

Here are some screenshots:

screen_1

screen_2

screen_3

share|improve this answer
    
Thank you so much! Great answer! I appreciate the screenshots as well! –  chrisjlee Jan 31 '12 at 17:50
3  
Most welcome :) The screenshots come from the blogpost that's linked above :P –  nitstorm Jan 31 '12 at 17:51
    
This doesn't work with the latest Ubuntu. Can we get an updated post here? –  A T Jul 30 '12 at 21:34
    
@AT How exactly does it not work? What error messages are getting? The PPA is there for the precise series... –  Jacob Johan Edwards Aug 5 '12 at 6:28
    
I was running 12.10. –  A T Aug 6 '12 at 8:02
show 1 more comment

You can also change the grub default boot entry from the command line without having to install any additional tool. This won't change the order in the list but it will allow a different OS to boot by default, which sounds like what you may want anyway.

First, make a backup copy of /etc/default/grub. In case something goes wrong, you can easily revert to the known-good copy.

sudo cp /etc/default/grub /etc/default/grub.bak

Then edit the file using vim or the text editor of your choice.

sudo vim /etc/default/grub

Find the line that contains GRUB_DEFAULT=0 and set it to GRUB_DEFAULT=x where x is the index of grub menu item to which you would like to boot to by default. Note that the menu items are zero-indexed. That means that the first item in the list is 0 and that the sixth item is actually 5. So to boot to the sixth item in the list, the line would read GRUB_DEFAULT=5.

Additionally, if you want to use a kernel in the "Previous Linux Versions" menu, you'll want to change GRUB_DEFAULT=0 to GRUB_DEFAULT="2>x" (make sure to include the quotations), where x is the placement of the old kernel on the sub-list (assuming the "Previous Linux Versions" is third on the main list). Remember that the list always begins counting at 0.

Then build the updated grub menu.

sudo update-grub
share|improve this answer
1  
Last I looked grub2 generates so many entries on the fly that it's really hard to figure out what number to use for an entry. –  Joe Jun 20 '12 at 17:53
9  
Using an index can be pretty messy - the list of OSes can change after an update. But you can have a look into /boot/grub/grub.cfg and search for the name of desired default OS. Then use the quoted name instead of an index. Example: GRUB_DEFAULT="Microsoft Windows XP Professional (on /dev/sda1)" instead of GRUB_DEFAULT=7 –  geekQ Dec 9 '12 at 11:57
add comment

From the tombuntu site (article by Tom):

GRUB can be configured using the /etc/default/grub file. Before you make any changes to it, it may be a good idea to back it up by creating a copy:

sudo cp /etc/default/grub /etc/default/grub.bak

You can restore the copying the backup over the original:

sudo cp /etc/default/grub.bak /etc/default/grub

Open the file using the text editor with root privileges:

gksu gedit /etc/default/grub

The line GRUB_DEFAULT=0 means that GRUB will select the first menu item to boot. Change this to GRUB_DEFAULT=saved. This change will make it easier to change the default item later.

Save and close the file. Run this command to apply your changes to GRUB’s configuration:

sudo update-grub

The configuration change we made allows the grub-set-default and grub-reboot commands to be used at any time. These allow you to change the default boot item permanently or only for the next boot, respectively.

Run grub-set-default or grub-reboot (with sudo) with the number of the menu item to boot (the first item is 0). This command will change the default to the second item:

sudo grub-set-default 1
share|improve this answer
5  
This answer is taken almost verbatim from tombuntu.com/index.php/2011/09/25/…. Please give credit where credit is due. –  James McMahon Nov 6 '12 at 23:00
add comment

Open up a terminal window (Ctrl+Alt+T), or press Alt+F2.

Type gksu nautilus and press Enter.

That will open up the file browser Nautilus with permission to change files owned by root.

Navigate to the file /boot/grub/grub.cfg and double-click to open the file in a text editor.

Cut, move and paste the sections in that file that belongs to different operating systems. You must be very careful when doing this, as if you do it wrong then you won't be able to boot anymore. Windows boot can always be repaired with the tools from a windows installation disc (FIXMBR), that overwrites GRUB-MBR with a typical Windows-MBR.

I have tested it from Ubuntu 9.04 to 12.04 and it has worked fine every time.

But I have only tried to move the Windows boot section to the top of the list to make it become the default.

If my memory is correct, each boot menu section in the file starts with a begin ... and ends with an ...end. And spans multiple text rows.

The text in that file has become a bit more complicated and it doesn't look the same in the last Ubuntu version as in previous versions. So use your brain to save you from doing a mistake.

share|improve this answer
2  
Don't you have to run sudo update-grub at some point? –  Eliah Kagan Jul 6 '12 at 12:01
2  
/boot/grub/grub.cfg is being overwritten at every package installed/updated triggering an update of Grub, effectively invoking update-grub. And that generates a new grub.cfg. Therefore, configuring Grub is done in files in the /etc directory as explained by the other answers, to make sure it's persistent. –  gertvdijk Sep 19 '12 at 20:16
add comment

I tried the following and got good results.

Open up a terminal window (Ctrl+Alt+T),

Type sudo gksu nautilus and press Enter. Type in your user password.

Navigate to the file /boot/grub/grub.cfg. Copy and Paste the file into same directory, should create copy of the grub.cfg file for backup purposes. Then double-click grub.cfg to open the file in a text editor.

In the file you will find the line (set default="0"). Edit the 0 to the line number in Grub that you want to load. Mine was the sixth line, so I used 5, as the first line is considered 0. Save the file. Reboot the pc and if you chose the correct line it will be the highlighted one when Grub loads.

Good luck

share|improve this answer
4  
as you can see in the beginning of the file, it says that you should not do this. instead edit /etc/default/grub and then run update-grub. –  sazary Oct 23 '12 at 11:32
1  
and I wouldn't recommend to gksu nautilus either. Too easy to drop a bomb in your system from there. –  sylvainulg Mar 28 '13 at 9:20
add comment

protected by Community Oct 29 '12 at 7:39

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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