How To Install a Mainline Linux Kernel in Ubuntu

Note: This article was updated on Thursday, July 31st, 2025 and will work with newer Ubuntu releases.

By default, Ubuntu systems run with the Ubuntu kernels provided by the Ubuntu repositories. To get unmodified upstream kernels that have new features or to confirm that upstream has fixed a specific issue, we often need to install the mainline Kernel. The mainline kernel is the most recent version of the Linux kernel released by the Linux Kernel Organization. It undergoes several stages of development, including merge windows, release candidates, and final releases. Mainline kernels are designed to offer the latest features and improvements, making them attractive to developers and power users. Kernel.org lists the available Kernel versions.

To install the mainline kernel, we need a package called mainline available from the cappelikan personal package archive (PPA). To add PPA for the mainline package, use the following command:

sudo add-apt-repository ppa:cappelikan/ppa

Ensure pkexec is installed:

sudo apt install pkexec

Run the following commands to update the repository and install the mainline utility:

sudo apt update
sudo apt install mainline

Once installed, we can check the available latest mainline and the point release using the following command:

mainline --check

For example, the latest stable kernel at the time of writing this article was 6.2.12.

$ sudo mainline --check
mainline 1.2.5
Distribution: Ubuntu 22.04.2 LTS
Architecture: amd64
Running kernel: 5.15.0-43-generic
Updating from: 'https://kernel.ubuntu.com/~kernel-ppa/mainline/'
OK
Fetching individual kernel indexes...
Found installed : 5.15.0-43.46
Latest update: 6.2.12
Latest point update: 5.15.108
----------------------------------------------------------------------

If you want the very latest unstable mainline, add --include-unstable to the command, eg:

# mainline --check --include-unstable
mainline 1.2.5
Distribution: Ubuntu 22.04.2 LTS
Architecture: amd64
Running kernel: 5.15.0-43-generic
Updating from: 'https://kernel.ubuntu.com/~kernel-ppa/mainline/'
OK
Fetching individual kernel indexes...
Found installed : 5.15.0-43.46
Latest update: 6.3.0-rc7
Latest point update: 5.15.108
----------------------------------------------------------------------

We see Kernel 6.3.0-rc7 is available.

Installing the latest mainline kernel

To install the latest stable kernel (6.2.12 in our example), all you have to do is run the following command:

$ sudo mainline --install-latest

To install the latest point Kernel (5.15.0-43.46), run the following command:

$ sudo mainline --install-point

To install the latest unstable Kernel (6.3.0-rc7), run the following command:

$ sudo mainline --install 6.3.0-rc7

For more information and options run mainline --help

$ mainline --help
mainline 1.2.5
Distribution: Ubuntu 22.04.2 LTS
Architecture: amd64
Running kernel: 5.15.0-43-generic
  
mainline 1.2.5 - Ubuntu Mainline Kernel Installer
  
Syntax: mainline <command> [options]
  
Commands:
  
--check Check for kernel updates
--notify  Check for kernel updates and notify current user
--list  List all available mainline kernels
--list-installed  List installed kernels
--install-latest  Install latest mainline kernel
--install-point Install latest point update for current series
--install <name>  Install specified mainline kernel(1)(3)
--uninstall <name>  Uninstall specified kernel(1)(2)(3)
--uninstall-old Uninstall all but the highest installed version(3)
--download <name> Download specified kernels(2)
--delete-cache  Delete cached info about available kernels
  
Options:
  
--include-unstable  Include unstable and RC releases
--exclude-unstable  Exclude unstable and RC releases
--debug Enable verbose debugging output
--yes Assume Yes for all prompts (non-interactive mode)
  
Notes:
(1) A version string taken from the output of --list
(2) One or more, comma-seperated
(3) The currently running kernel will always be ignored

Once the Kernel is installed, reboot

$ sudo systemctl reboot

When the system boots, verify the new Kernel is loaded

$ uname -r
6.3.0-060300rc7-generic

Enjoy

How to Confirm Virtual to Physical Memory Mappings for PMem and FSDAX Files

How to Confirm Virtual to Physical Memory Mappings for PMem and FSDAX Files

Are you curious whether your application’s memory-mapped files are really using Intel Optane Persistent Memory (PMem), Compute Express Link (CXL) Non-Volatile Memory Modules (NV-CMM), or another DAX-enabled persistent memory device? Want to understand how virtual memory maps onto physical, non-volatile regions? Let’s use easily adaptable scripts in both Python and C to confirm this on your Linux system, definitively.

Why Does This Matter?

With the advent of persistent memory and DAX (Direct Access) filesystems, applications can memory-map files directly onto PMem, bypassing the traditional DRAM page cache. This promises significant performance and durability improvements for data-intensive workloads and databases, such as SQLite, Redis, and others.

Read More
How To Emulate CXL Devices using KVM and QEMU

How To Emulate CXL Devices using KVM and QEMU

What is CXL?

Compute Express Link (CXL) is an open standard for high-speed central processing unit-to-device and CPU-to-memory connections, designed for high-performance data center computers. CXL is built on the PCI Express physical and electrical interface with protocols in three areas: input/output, memory, and cache coherence.

CXL is designed to be an industry open standard interface for high-speed communications, as accelerators are increasingly used to complement CPUs in support of emerging applications such as Artificial Intelligence and Machine Learning.

Read More
How To Install and Boot VMWare VSphere/ESXi from Persistent Memory (or not)

How To Install and Boot VMWare VSphere/ESXi from Persistent Memory (or not)

In a previous post I described how to install and boot Linux using only Persistent Memory, no SSDs are required. For this follow on post, I attempted to install VMWare VSphere/ESXi v7.0u2 onto the persistent memory.

TL;DR - It doesn’t work. The installer doesn’t list the PMem devices, and I was unable to find a way to manually select the PMem device(s).

I assume you followed the previous post to configure sector namespaces that we’ll use to install ESXi.

Read More