This morning linux-image-3.5.0-26-generic was installed during a software update. On my laptop this proved to be unusable after 10 minutes. I changed to linux-image-3.5.0-24-generic and all seems fine. I have updated the default grub2 selection to the 24-generic. How can I lock the default grub selection to this value so subsequent updates don't overwrite and make themselves default?


how to lock a kernel grub entry

With a bit of command line trickery, you can get the default of grub to always be a particular grub entry no matter when a new kernel is installed or updated.

In a terminal type:

fgrep menuentry /boot/grub/grub.cfg

This will display all your grub entries - for example

enter image description here

Highlight the entry you want to default to - for example 'Ubuntu, with Linux 3.2.0-31' in the screen-shot. Right click and choose copy


gksu gedit /etc/default/grub

Change the entry



GRUB_DEFAULT='2>Ubuntu, with Linux 3.2.0-31-generic'

i.e. paste the entry you want (including the quotes) BUT PREFIX with the text 2>

Save, then type

sudo update-grub

The text 2> is important because this informs Grub that the entry to boot from exists in the sub-menu called "Previous Linux entries"


you can use this tool, Grub Customizer. To download, Open terminal and type:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer [enter]

sudo apt-get update [enter]

sudo apt-get install grub-customizer [enter]

Open dash and search grub customizer, and run it. Edit configuration with this tool.it's easy . Go to General Settings to edit the default, time boot etc

enter image description here

  • Thanks - I installed that and was able to edit the default entry so to the version I desired. I did NOT notice how to "lock" the default so that new kernels wouldn't overwrite and make themselves default – pfeiffep Feb 28 '13 at 20:34

I just searched and found this file:


Command grub-mkconfig (or update-grub) uses this file for default values. Try editing line GRUB_DEFAULT=0 to GRUB_DEFAULT=1.

  • Thats only good until the next kernel upgrade happens. – guntbert Feb 28 '13 at 17:26
  • I want to insure that on subsequent kernel updates grub2 default selection REMAINS on whatever I've modified in the grub2 menu. Or is it possible to have a dual boot config based on kernel level? – pfeiffep Feb 28 '13 at 17:32
  • Oh, I understand. This way Kernel3 would take Kernel2 place and default=1 would point to Kernel 2, instead of Kernel1. But it seems GRUB_DEFAULT can be set to a string. I don't have the exact answer, but I thinks it's here: link. – Balgerda Feb 28 '13 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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