Make Grub2 Boot Older Kernel Version in Ubuntu 20.04

In a Linux system, we may have multiple kernels installed. Usually, it is the latest kernel configured to be the default one the system boot loader will use during automatic boot if there is no manual kernel choosing. In many cases, such as there is no driver ready yet for some devices in newer kernels, we may choose to use an older version of kernel installed to the system. In this post, we will go through the steps to make the system boot loader grub (version 2) to boot the older kernel installed to the system on Ubuntu 20.04.

Find the list of kernels installed and the grub menu entries

We need to first find out the grub menu entries. The tool grub-mkconfig prints the grub configuration file content it generates to STDOUT. We can grep relevant content from its STDOUT as follows.

$ sudo grub-mkconfig | grep -E 'submenu |menuentry '

You will see output as follows.

...
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-84d2ae45-10d0-4cd9-a958-85e582df668b' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-84d2ae45-10d0-4cd9-a958-85e582df668b' {
    menuentry 'Ubuntu, with Linux 5.4.0-33-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-33-generic-advanced-84d2ae45-10d0-4cd9-a958-85e582df668b' {
    menuentry 'Ubuntu, with Linux 5.4.0-33-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-33-generic-recovery-84d2ae45-10d0-4cd9-a958-85e582df668b' {
Found linux image: /boot/vmlinuz-4.15.0-101-generic
Found initrd image: /boot/initrd.img-4.15.0-101-generic
    menuentry 'Ubuntu, with Linux 4.15.0-101-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-101-generic-advanced-84d2ae45-10d0-4cd9-a958-85e582df668b' {
    menuentry 'Ubuntu, with Linux 4.15.0-101-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-101-generic-recovery-84d2ae45-10d0-4cd9-a958-85e582df668b' {
...

Here, we use the entry “Ubuntu, with Linux 4.15.0-101-generic” under menu “Advanced options for Ubuntu” as an example.

During booting time, grub reads the grub configuration file. grub-mkconfig that can generate the grub configuration file. We can update the grub-mkconfig‘s configuration file to change the grub configuration file.

Set grub-mkconfig configuration file

Grub has a configuration file under /etc/default/grub. The configuration file has a variable GRUB_DEFAULT specifying the default choice in grub.

Here, what we need to figure out is the format to select the 2 levels of the menu entries. In the configuration parameter, these 2 levels of entries should be all specified with a character > to separate them.

So for our purpose, change the config file by changing the line for setting GRUB_DEFAULT to

GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 4.15.0-101-generic"

Regenerate grub configuration file

We now can generate the configuration file. In Debian Linux distros and derivatives, there is a tool update-grub to do this by calling grub-mkconfig.

$ sudo update-grub

After it finishes successfully, the default entry in the Grub2 configuration file will be the one we set when we boot the Linux system next time.

Similar Posts

  • Additional Repositories for Fedora Linux

    Fedora’s repositories provide most of the software packages needed when using Linux. However, for various consideration, they do not provide some packages, such as MPlayer, ffmpeg. Fortunately, some community maintained repository provides these software. And they may also package propriety software, such as ATI fglrx dive, NVIDIA driver, into rpm packages. In this post, we…

  • C++ Reference and Styles

    C++ References Reference of the C++ Language Library, with detailed descriptions of its elements and examples on how to use its functions: http://www.cplusplus.com/reference/ C++ reference: http://www.cppreference.com/w/ C++ Styles I compile a list of C++ styles on the Internet. http://geosoft.no/development/cppstyle.html http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml http://www.mactech.com/articles/develop/issue_02/C%2B%2B_Style_Guide_v007.html http://www.cs.uga.edu/~dkl/1302/Fall99/style.html Read more: GNU C Reference Manual Reference: Special HTML Characters How to generate…

  • How to test whether a file exists and is a block special file in Python on Linux?

    Bash has a -b test to test whether a file exists and is a block special file. -b file True if file exists and is a block special file. How to do this in Python? Python’s stat module provides the similar functions for the C standard APIs and macros underlining such as stat() and S_ISBLK()….

  • How to force a checkpointing of metadata in HDFS?

    HDFS SecondaraNameNode log shows 2017-08-06 10:54:14,488 ERROR org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Exception in doCheckpoint java.io.IOException: Inconsistent checkpoint fields. LV = -63 namespaceID = 1920275013 cTime = 0 ; clusterId = CID-f38880ba-3415-4277-8abf-b5c2848b7a63 ; blockpoolId = BP-578888813-10.6.1.2-1497278556180. Expecting respectively: -63; 263120692; 0; CID-d22222fd-e28a-4b2d-bd2a-f60e1f0ad1b1; BP-622207878-10.6.1.2-1497242227638. at org.apache.hadoop.hdfs.server.namenode.CheckpointSignature.validateStorageInfo(CheckpointSignature.java:134) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.doCheckpoint(SecondaryNameNode.java:531) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.doWork(SecondaryNameNode.java:395) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode$1.run(SecondaryNameNode.java:361) at org.apache.hadoop.security.SecurityUtil.doAsLoginUserOrFatal(SecurityUtil.java:415) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.run(SecondaryNameNode.java:357) It seems the checkpoint…

  • How to boot Linux Mint to the console by default?

    How to boot Linux Mint to the console by default? (that is, the run level 3). 2 methods introduced here to boot Linux Mint to console/command line. Method 1 (may only work for earlier releases; check method 2 below): set kernel option. Edit /etc/default/grub and add text to GRUB_CMDLINE_LINUX_DEFAULT: GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash text” Then, re-generate grub…

  • Cryptographic token 101

    Cryptographic tokens, or crypto tokens, are tradable digital units of assets that reside on blockchains. These tokens have become increasingly popular in recent years due to the rise of cryptocurrencies and the growing interest in non-fungible tokens (NFTs). Both fungible and non-fungible tokens play a significant role in the world of blockchain technology and digital…

One Comment

  1. I want to thank you.

    My new kernel came default and it was not working. I fixed the issue, thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *