Manage Ubuntu Kernels


Display and peripheral issues are always related to the kernel drivers and modules. Upgrade to a newer kernel version might help.

There are many tools to manage kernels[1]:

  1. Manage with the ubuntu-mainline-kernel.sh[2]
  2. Manage with the Ubuntu Mainline Kernel Installer[3]
  3. Manage with dpkg[4]
  4. Low Latency vs Generic Kernel
  5. Upgrade to a Low Latency Kernel
  6. The GRUB[5] Configuration
  7. Remove Unused Kernel

Quick Summary

  1. Ubuntu Mainline Kernel Installer runs on kernel 5.0.0 and above.
  2. It’s recommended to download all packages and install with dpkg on LTS 18.04.
  3. To use the low latency kernel, use dpkg to install all generic and low latency packages at the same time.
  4. If it’s required to install the wireless kernel module after switching to the low latency, it must be recompiled with the low latency heads and install again.

Manage with the ubuntu-mainline-kernel.sh

It fails to download all files on many kernel versions. I have successfully installed the 5.7.1 but fails on any higher versions. If this happens, try to install a newer ubuntu-mainline-kernel.sh or wait for a few days.

Installation

To install the shell script:

$wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
$sudo install ubuntu-mainline-kernel.sh /usr/local/bin/

Cloning the repository needs to remove the execute property before installing:

$git clone https://github.com/pimlie/ubuntu-mainline-kernel.sh
$chmod -x ubuntu-mainline-kernel.sh
$sudo install ubuntu-mainline-kernel.sh /usr/local/bin/

Usage

To install kernel 5.7.1:

$sudo ubuntu-mainline-kernel.sh -i 5.7.1

To remove the shell script:

$sudo rm /usr/local/bin/ubuntu-mainline-kernel.sh

Other parameters:

  1. -c to find the latest available and installed kernel versions.
  2. -r to list all available kernel versions.
  3. -l to list all installed kernel version using mainline tools.
  4. -ll to install the low-latency version. The default is the generic version.

Manage with the Ubuntu Mainline Kernel Installer

It scans existing and available kernel versions. Kernel installation is straight forward though only the generic version is supported.

Installation

I install it from a new repository. The source code is available and may be compiled manually.

$sudo add-apt-repository ppa:cappelikan/ppa
$sudo apt update
$sudo apt install mainline

Usage

Search for Ubuntu Mainline Kernel Installer to launch. Click the kernel version to install or remove. Move the pointer over the kernel version number to display available and installed packages.

Manage with dpkg

Download the .deb packages from Ubuntu Mainline Kernel Archive. Install the generic before the low latency.

$sudo dpkg –i *.deb

Low Latency vs Generic Kernel

The low-latency kernel will ask the CPU to pay more attention to processes that need immediate attention. It increases the context switch but feels more responsive especially on video editing and gaming. On a multi-core system, it would increase the overall utilization.[6][7]

Upgrade to a Low Latency Kernel

To use the low latency version, download the low latency .deb packages from Ubuntu Mainline Kernel Archive[8].

$sudo dpkg –i *.deb

Please install the generic version before the low latency. This prevents the dependency problems from installing low latency Linux headers.

Without the low latency Linux headers, the rtl8812au kernel module fails to load.

Unpacking linux-headers-5.9.12-050912-lowlatency (5.9.12-050912.202012020835) ...
dpkg: dependency problems prevent configuration of linux-headers-5.9.12-050912-lowlatency:
 linux-headers-5.9.12-050912-lowlatency depends on linux-headers-5.9.12-050912; however:
  Package linux-headers-5.9.12-050912 is not installed.

dpkg: error processing package linux-headers-5.9.12-050912-lowlatency (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-headers-5.9.12-050912-lowlatency

After successfully installing the low latency Linux headers, the rtl8812au kernel module is recompiled during installation and the device is ready to work.

Setting up linux-headers-5.9.12-050912-lowlatency (5.9.12-050912.202012020835) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.9.12-050912-lowlatency

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
'make' -j4 KVER=5.9.12-050912-lowlatency KSRC=/lib/modules/5.9.12-050912-lowlatency/build..............
Signing module:
 - /var/lib/dkms/8812au/5.6.4.2_35491.20191025/5.9.12-050912-lowlatency/x86_64/module/88XXau.ko
Secure Boot not enabled on this system.
cleaning build area...

DKMS: build completed.

88XXau.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.9.12-050912-lowlatency/updates/dkms/

depmod...

DKMS: install completed.

Kernel preparation unnecessary for this kernel.  Skipping...

The GRUB Configuration

GRUB is hidden by default. It[9] is said to press and hold the Esc or Shift key after the BIOS splash screen would bring up the GRUB menu. For convenience, I decided to display for 5 seconds at boot time to save my finger.

Edit the Configuration File

Edit /etc/default/grub:

  1. Use “#” to disable “GRUB_TIMEOUT_STYLE=hidden”. Or replace ‘hidden’ by ‘menu’[10] as “GRUB_TIMEOUT_STYLE=menu”
  2. Set GRUB to display for 5 seconds as ‘GRUB_TIMEOUT=5’.

Update to apply change:

$sudo update-grub

Use Boot-Repair

Install[12] a GUI tool to simplify the job:

$sudo add-apt-repository ppa:yannubuntu/boot-repair
$sudo apt update
$sudo apt install boot-repair

Launch Boot Repair and open [Advanced options] → [More options] tab → set the “Unhide boot menu” for 5 seconds. Click [Apply] button.

Choose Kernel to Boot in GRUB

Now, when grub is displayed, select “Advanced options for Ubuntu”. It displays all available kernels to boot.

Grub at Boot Time
Boot ubuntu with the selected kernel version.

Remove Unused Kernel

To remove all unused kernels:

$sudo apt --purge autoremove

To remove a specified kernel, use dpkg to list all installed kernels and apt-get to remove:

$sudo dpkg -l | egrep -i 'linux-image | linux-headers'
ii  linux-headers-5.4.0-56                        5.4.0-56.62                                 all          Header files related to Linux kernel version 5.4.0
ii  linux-headers-5.4.0-56-generic                5.4.0-56.62                                 amd64        Linux kernel headers for version 5.4.0 on 64 bit x86 SMP
ii  linux-headers-5.9.10-050910                   5.9.10-050910.202011221708                  all          Header files related to Linux kernel version 5.9.10
ii  linux-headers-5.9.10-050910-generic           5.9.10-050910.202011221708                  amd64        Linux kernel headers for version 5.9.10 on 64 bit x86 SMP
ii  linux-headers-5.9.11-050911                   5.9.11-050911.202011241443                  all          Header files related to Linux kernel version 5.9.11
ii  linux-headers-5.9.12-050912                   5.9.12-050912.202012020835                  all          Header files related to Linux kernel version 5.9.12
ii  linux-headers-5.9.12-050912-generic           5.9.12-050912.202012020835                  amd64        Linux kernel headers for version 5.9.12 on 64 bit x86 SMP
ii  linux-headers-5.9.12-050912-lowlatency        5.9.12-050912.202012020835                  amd64        Linux kernel headers for version 5.9.12 on 64 bit x86 SMP
$sudo apt-get remove linux-headers-5.4.0-56-generic

Style Guide

The Style used in AmigoTechNotes

Reference

  1. LinuxHint: Check and Update Ubuntu Kernel Version on Ubuntu 20.04
  2. GitHub: bkw777/mainline
  3. GitHub: pimlie/ubuntu-mainline-kernel.sh
  4. Dpkg: Debian Package Manager
  5. GNU GRUB
  6. AskUbuntu: Why choose a low latency kernel over a generic or real-time kernel?
  7. HO ADOTTATO UN CLUELESS USER: LOW-LATENCY KERNEL? WTF?!?!
  8. Ubuntu Mainline Kernel Archive (sorted by most recent build)
  9. ask ubuntu: Grub menu at boot time… “holding shift” not working
  10. gnu: 6.1 Simple configuration handling
  11. SourceForge: boot-repair
  12. LinuxConfig: Ubuntu Boot Repair

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.