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

  • How to install Windows or other OS and then bring to another computer by using a physical drive and Virtual Machine with QEMU
  • PXE-E23 Error BOOTx64.EFI GRUB booting is 0 bytes tftp pxe dhcp solution NBP filesize is 0 Bytes
  • vagrant install on Debian Mint Ubuntu Linux RHEL Quick Setup Guide Tutorial
  • RHEL 8 CentOS 8, Alma Linux 8, Rocky Linux 8 System Not Booting with RAID or on other servers/computers Solution for dracut and initramfs missing kernel modules
  • How to Upgrade to Debian 11 from Version 8,9,10
  • Ubuntu Linux Mint Debian Redhat Cannot View Files on Android iPhone USB File Transfer Not Working Solution
  • Virtualbox Best Networking Mode In Lab/Work Environment without using NAT Network or Bridged
  • debootstrap how to install Ubuntu, Mint, Debian install
  • Linux grub not using UUID for the root device instead it uses /dev/sda1 or other device name solution
  • How To Restore Partition Table on Running Linux Mint Ubuntu Debian Machine
  • Debian Ubuntu apt install stop daemon questions/accept the default action without prompting
  • iptables NAT how to enable PPTP in newer Debian/Ubuntu/Mint Kernels Linux
  • Grandstream Phone Vulnerability Security Issue Remote Backdoor Connection to 207.246.119.209:3478
  • Linux How to Check Which NIC is Onboard eth0 or eth1 Ubuntu Centos Debian Mint
  • VboxManage VirtualBox NAT Network Issues Managment Troubleshooting
  • Dell PowerEdge Server iDRAC Remote KVM/IP Default Username, Password Reset and Login Information Solution
  • Nvidia Tesla GPUs K40/K80/M40/P40/P100/V100 at home/desktop hacking, cooling, powering, cable solutions Tutorial AIO Solutions
  • Stop ls in Linux Debian Mint CentOS Ubuntu from applying quotes around filenames and directory names
  • Thunderbird Attachment Download Error Corrupt Wrong filesize of 29 or 27 bytes Solution
  • Generic IP Camera LAN Default IP Settings DVR