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.

Possible Duplicate:
How do I set Windows to boot as the default in the boot loader?
How do I change the grub boot order?

I installed a mainline kernel for testing purposes. I would like to set grub to boot from the older kernel by default.

I know I can set the GRUB_DEFAULT=0 setting for the first page of grub but how do I set it to boot by default from one kernel in the second page (Advanced page)?

I would prefer doing this without installing other software (ex. grub-customizer).

share|improve this question
    
@belacqua: It is not a duplicate. This question is about setting an older kernel that is not present in grub's first page of options as default. –  To Do Nov 13 '12 at 13:14
    
It seems like this case should be covered in the earlier questions, even if the method needs to be update for 12.10, older kernels, etc.. –  belacqua Nov 13 '12 at 15:26
1  
The question's use case is different, and the answer is very specific in a way that doesn't apply to the other claimed duplicates. I came here to solve this particular problem; not to change the boot order; nor to boot Windows. +1 for "not a duplicate". –  Robie Basak Mar 16 at 14:09

1 Answer 1

up vote 33 down vote accepted

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 the text editor of your choice (ie. gedit, etc.).

sudo gedit /etc/default/grub

Find the line that contains GRUB_DEFAULT=0 - this is what you'll want to edit to set the default. To know what to change it to, you must know where it is on the list (1st, 2nd, 3rd, etc.). For example, on my computer, I have:

  1. The Latest Kernel
  2. The Latest Kernel (Recovery mode)
  3. Previous Linux Versions
  4. Memory test (memtest86+)
  5. Memory test (memtest86+, serial console 115200)

If you choose the "Previous Linux Versions", you will see:

  1. Old Kernel
  2. Old Kernel (Recovery mode)
  3. Older Kernel
  4. Etc.

Essentially, all the older kernels that are still installed. These are sub-choices, of a sort. So in my case, since "Previous Linux Versions" is 3rd on the boot list, the first kernel inside of it would be "2>0", the second "2>1", and so on; counting on the list starts at 2>0 since grub uses 0 as the first option, not 1.

EDIT: As Bealer has stated below, using a numeric value can cause problems following system updates. Therefore, it's better to use a text default, i.e. GRUB_DEFAULT="Previous Linux versions>Ubuntu, with Linux 3.2.0-18-generic" (including quotes).

In summary, 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).

Save it, then build the updated grub menu.

sudo update-grub

I hope that wasn't too confusing; I might have babbled a little :/

share|improve this answer
    
Thanks very much. It worked but: 1. GRUB_DEFAULT=0 doesn't have the quotation marks by default. Changing to 1>2 requires quotation marks. 2. The third item in the list is "2" because the count starts from "0". –  To Do Nov 13 '12 at 13:17
6  
Using a numeric value can be problematic when updates occur. It's better to use a text default, ie: GRUB_DEFAULT="Previous Linux versions>Ubuntu, with Linux 3.2.0-18-generic" –  Bealer Jul 4 '13 at 16:45
2  
One can use sudo grub-mkconfig | less to see all of the possible options –  Nitz Feb 17 at 20:55
1  
This is a good solution, but even better is to open a /boot/grub/grub.cfg and there you will see all the manuentry and all the submenus. If you edit them, you can easy set the default ones, even change the Titles of the options in the grub list when restarting a computer. –  Aleks Apr 21 at 21:03
1  
It is definitely useful to examine /boot/grub/grub.cfg to determine the exact names to use. But do not change this file as it will be automatically regenerated by update-grub, including on updating packages. –  Robie Basak May 19 at 16:36

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.