2 min read

Learning Linux - Changing the Kernel

There are not so many guides that do not unecessarily overcomplicate things or only give out fragments of information
Learning Linux - Changing the Kernel
AI Generation: person changing ubuntu kernel in terminal. photorealistic

In what may end up being a bit of a feature, I'm going to document things I've learnt as I use Linux more and more in daily (work) life.

This first post focuses on changing the Kernal in Ubuntu, something that I needed to do while testing some software at work. The problem, I found, was that there were not so many guides that did not completely unecessarily overcomplicate things or only give out fragments of information.

Kernels control the hardware of a computer: they are the layer between the physical machine and human-controlable operating system. Different Kernels can be used for acheiving different (ideally better) control over hardware and are changed over time to allow for new features, so there are plenty of reasons to change them. In my initial use-case, testing compatibility was the goal.

Ubuntu has a write-up on Kernels here.

Here, I will lay out the few steps required to complete a change of Kernel in a Ubuntu (or Ubuntu-like) system.

To start with, it's good to have a list of the Kernels available to you:

$ dpkg --list | grep linux-image

And you can check the currently running kernel:

$ uname -r

Install a new kernel like any other package with APT:

$ sudo apt install linux-image-x.xx.x-xx-generic
(replace x.xx.x-xx-generic with whichever kernel is required)

Ensure the new package is not automatically removed, and add any extras (particularly need to avoid network issues):

$ sudo apt-mark hold linux-image-x.xx.x-xx-generic
$ sudo apt install linux-modules-extra-x.xx.x-xx-generic

Update Grub to enable the new Kernel:

$ sudo nano /etc/default/grub
#Add after the first uncommented commands (GRUB_CMDLINE_LINUX)
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
$ sudo update-grub
sudo reboot

Hit Esc as Ubuntu boots to change kernel.

Mastodon