Skip to content

Linux Foundations / Understand the system underneath ยท Step 23 of 38

Lesson: Installing and updating the kernelSwitch
โ† Linux Foundations

System administration

Installing and updating the kernel

Install a newer kernel with your package manager and boot it safely.

The safest way to get a new kernel is the same way you get other software: from your distribution. Its packages are built and tested for your system and receive security fixes.

Check what you have

bash
uname -r
6.8.0-45-generic

List installed kernel packages:

bash
dpkg --list 'linux-image*'      # Debian, Ubuntu
rpm -q kernel                   # Fedora, RHEL family
pacman -Q linux                 # Arch

Update it

On Debian and Ubuntu:

bash
sudo apt update
sudo apt full-upgrade

Package names such as linux-image-amd64 (Debian on 64-bit PCs) and linux-image-generic (Ubuntu) are metapackages. They depend on the current kernel package, so keeping one installed brings in new kernels.

On Fedora and RHEL family systems:

bash
sudo dnf upgrade kernel

On Arch, upgrade the whole system with sudo pacman -Syu. Partial upgrades are not supported there.

Reboot to use it

Installing puts new files on disk. The old kernel keeps running until you restart. (Live patching services can apply some fixes without a reboot, but they do not replace this step in general.)

bash
sudo reboot

Afterwards, check uname -r again.

Keep a fallback

Debian, Ubuntu and Fedora normally keep older kernels installed. If the new one fails, choose the older entry in the boot loader menu, often under "Advanced options" in GRUB on Debian and Ubuntu. The menu may be hidden by default.

Fedora limits how many are kept with installonly_limit, 3 by default. Arch replaces the linux package in place, so you can also install linux-lts as a fallback.

On Debian and Ubuntu, sudo apt autoremove can remove old kernels that are no longer needed. Read the list before you confirm, and do not remove the running one.

Package hooks normally build the initramfs and update the boot menu for you.

Building from source

You can also build the kernel from kernel.org. The broad steps are configuring (make menuconfig), building (make), then sudo make modules_install and sudo make install. It needs build tools and time, and you must handle updates yourself. Learners should try it only in a virtual machine.

Practise package management in the packages lab.

Try it

  1. Run uname -r and list your installed kernel packages.
  2. On Debian or Ubuntu, run apt list --upgradeable after sudo apt update and look for linux- packages.
  3. Check how much space /boot has with df -h /boot. A new kernel needs free space there.

Check your understanding

Installing and updating the kernel

All 5 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.