Linux Grub not booting the intended kernel solution in Debian, Mint, Ubuntu how to specify which kernel to boot by default

Traditionally kernels were numbered starting from 0 but by default the "new style" of grub boot loading considers each subkernel item to be different so if you have 3 entries for 4.40-148 rather than counting for 1.

To get the expected behavior let's show this example and how we can boot it

We do a grep on menuentry in /boot/grub/grub.cfg to see all of the bootable kernels rather than scrolling through loads of extra entries we don't care about (though grub does care and won't boot without them so don't mess things up here if you are editing grub.cfg!)

grep menuentry /boot/grub/grub.cfg


if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'Linux Mint 17.2 MATE 64-bit' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-61f69d26-da8e-4317-a5cb-834402b90501' {
submenu 'Advanced options for Linux Mint 17.2 MATE 64-bit' $menuentry_id_option 'gnulinux-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-148-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-148-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-148-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-148-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-134-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-134-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-134-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-134-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-108-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-108-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-108-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-108-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-98-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-98-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-98-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-98-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-64-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-64-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 4.4.0-64-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-64-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 3.19.0-80-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-80-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 3.19.0-80-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-80-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 3.16.0-38-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-38-generic-advanced-61f69d26-da8e-4317-a5cb-834402b90501' {
    menuentry 'Linux Mint 17.2 MATE 64-bit, with Linux 3.16.0-38-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-38-generic-recovery-61f69d26-da8e-4317-a5cb-834402b90501' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {

 

Say we want to boot 3.19.0-80

If we look at all the unique kernels listed (not duplicates) and count from 0 then 3.19 is #5

Let's edit the default grub file to tell it to boot 3.19 or menu entry #5

sudo vi /etc/default/grub


GRUB_DEFAULT=5
GRUB_DISABLE_SUBMENU=y

*Note we need the GRUB_DISABLE_SUBMENU=y above or things won't work as expected and won't restore the good old "legacy" days of how grub handles kernel entries.

Update grub so the changes take effect

sudo update-grub


After rebooting you should boot into the desired kernel and don't have to rely on the normally correct assumption that the latest and newest kernel is the one you should boot by default/automatically.

 


Tags:

linux, grub, booting, kernel, debian, mint, ubuntu, specify, defaulttraditionally, kernels, numbered, default, quot, loading, considers, subkernel, entries, grep, menuentry, cfg, bootable, scrolling, loads, editing, feature_menuentry_id, xy, menuentry_id_option, export, gnu, os, gnulinux, cb, submenu, advanced, generic, mode, memtest, console, listed, duplicates, edit, entry, sudo, vi, etc, grub_default, grub_disable_submenu, restore, legacy, handles, update, rebooting, desired, rely, assumption, newest, automatically,

Latest Articles

  • Bad Power Supply Issue Story Diagnosing Troubleshooting
  • Getting started with AI (Artificial Intelligence) in Linux / Ubuntu using by deploying LLM (Language Learing Models) using Ollama LLMA
  • microk8s kubernetes how to install OpenEBS
  • Flash LSI MegaRAID 2208 to IT mode in Linux Mint/Debian/Ubuntu
  • LSI MegaRAID in Linux Ubuntu / Centos Tutorial Setup Guide megacli
  • Convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/413. convert-im6.q16: no images defined `pts-time.jpg' @ error/convert.c/ConvertImageCommand/3258. solution ImageMagick P
  • Apache PHP sending expires header solution cannot use cache with CDN
  • How to install virt-manager in Mint 22/Ubuntu 22
  • Infiniband Guide
  • python mysql install error: /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found mysql_config --version
  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide