I am using Ubuntu 14.04 with Linux kernel 3.19.0.25. Earlier I had some issues with 3.19.0.28, my screen was freezing on boot, with 25 I am not facing those issues. So I want to make 25 my default kernel. To switch to 25 I usually have to select advance boot options in Grub screen and select this linux kernel version.
1 Answer
Step 1: Run awk '/\$menuentry_id_option/ {print $(NF-1) }' /boot/grub/grub.cfg | less
in terminal. This will tell unique id for each grub OS entry. For example, I have the following output:
'gnulinux-simple-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-advanced-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-4.1.0-040100rc2-generic-advanced-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-4.1.0-040100rc2-generic-recovery-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-3.19.0-28-generic-advanced-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-3.19.0-28-generic-recovery-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-3.19.0-26-generic-advanced-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-3.19.0-26-generic-recovery-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-3.13.0-63-generic-advanced-86df21bf-d95f-435c-9292-273bdbcba056'
'gnulinux-3.13.0-63-generic-recovery-86df21bf-d95f-435c-9292-273bdbcba056'
Step 2
Run sudo sed -i 's/GRUB_DEFAULT=0/GRUB_DEFAULT=X/g' /etc/default/grub; sudo update-grub
. Replace X in GRUB_DEFAULT=X
with the menuentry_id
that corresponds to your desired OS version. For instance, if I wanted to boot with kernel 3.19.0-26, i'd replace x with gnulinux-advanced-86df21bf-d95f-435c-9292-273bdbcba056>gnulinux-3.19.0-26-generic-advanced-86df21bf-d95f-435c-9292-273bdbcba056
. If your kernel choice isn't the 'simple' option you'll need to add the parent submenu menuentry_id_option as a part of the grub default.
Step 3: Reboot. Confirm that you have appropriate kernel booted with uname -a
or cat /proc/cmdline
NOTE: If you get output from this command you are probably on a newer version of grub. This documentation is a bit out of date when it comes to menuentry ids, but could help: https://help.ubuntu.com/community/Grub2/Submenus#Submenu_Display
-
The default option has changed, but it's not what I wanted man. See my grub menu looks like this. ubuntu, advanced boot options, memtest, memtest again, windows 7. I go to advanced boot options and select linux 3.19.0.25. Your code told me to make 3 the default option. I made it the default option and I rebooted. Now the cursor is on memtest when the Grub opens. That's not what I want. I want Grub to open ubuntu with 3.19.0.25 when I select the first Ubuntu in the list. So I don't have to open advanced options and select a different kernel version.– AdityaSep 26, 2015 at 20:12
-
@Aditya, 3 was just an example. You'd need to select an entry that corresponds to your desired kernel. I'm going to recheck my code, though, but basic idea is that you set GRUB_DEFAULT to a specific entry from /boot/grub/grub.cfg file Sep 26, 2015 at 20:20
-
3 happened to be the option I needed to set too man. I understand it was an example. Basically the option I want to make default is on a sub-level or within advanced options container.– AdityaSep 26, 2015 at 20:22
-
@Aditya OK, run that first code again, and find the part that says something line this :
gnulinux-3.19.0-25-generic-advanced-86df21bf-d95f-435c-9292-273bdbcba056
. Now take that line and copy that into the code in step #2. That should give it the exact menu entry, instead of messing with numbers. Let me know if that helps Sep 26, 2015 at 20:37