Kahibaro
Discord Login Register

4.3 Kernel Management

Overview

Kernel management covers how you interact with, inspect, update, and customize the Linux kernel on a running system. In this chapter you will:

Details about “what the kernel is” and “kernel modules” are handled by their own sections; here we focus on managing kernels as a whole in a real system.

Identifying the Running Kernel

Most kernel management tasks start by determining what you are currently running.

Checking kernel version

The primary tool:

bash
uname -r

Typical output:

text
6.8.0-47-generic

This string usually includes:

Other useful variants:

bash
uname -a        # full kernel + architecture + hostname info
uname -v        # kernel build date and build string

You can also see the kernel version in /proc/version:

bash
cat /proc/version

Mapping version to distribution kernel packages

Distributions ship the kernel as normal packages. Common patterns:

To find installed kernel packages:

bash
# Debian/Ubuntu
dpkg -l | grep linux-image
# RHEL/Fedora
rpm -qa | grep '^kernel'
# Arch
pacman -Qs '^linux'
# openSUSE
rpm -qa | grep '^kernel'

Kernel Release Types and Flavors

Distributions often provide multiple kernel “tracks” and flavors. Choosing the right one is part of kernel management.

Stable, LTS, and distribution kernels

Upstream kernels (from kernel.org) have:

Distributions usually:

Kernel flavors

You may see multiple flavors on the same distribution:

Choosing flavors:

Kernel Updates and Package Management

Kernels are updated through your distribution’s package manager, not by overwriting files manually.

How kernel updates are delivered

On most systems, regular system updates also pull in kernel updates:

bash
# Debian/Ubuntu
sudo apt update
sudo apt full-upgrade
# Fedora
sudo dnf upgrade
# Arch
sudo pacman -Syu

What happens during a kernel update:

You can see both current and installed kernels:

bash
uname -r            # currently running
# and then:
dpkg -l | grep linux-image   # or rpm/pacman as above

Security updates and reboot planning

Security advisories often include kernel vulnerabilities. Kernel management therefore includes:

For desktops you usually:

For servers you might:

Live patching (no‑reboot kernel security updates)

Some distributions and vendors provide live patching:

Characteristics:

Usage is vendor‑specific, but management tasks typically include:

Managing Multiple Kernels

Many distributions keep several kernel versions installed so you can fall back if a new kernel breaks something.

Listing installed kernels

Use package manager queries:

bash
# Debian/Ubuntu
dpkg -l | grep linux-image
# Fedora/RHEL
rpm -qa | grep '^kernel'
# Arch
pacman -Q | grep '^linux'

On some systems, kernels are also visible in /boot:

bash
ls /boot/vmlinuz*
ls /boot/initrd*

Selecting a kernel at boot

Kernel selection is typically done by the bootloader.

With GRUB2, you often have:

To enable the GRUB menu on systems where it’s hidden:

bash
sudo nano /etc/default/grub

Look for:

Example to show the menu for 5 seconds:

text
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=5

Then regenerate GRUB config:

bash
# Debian/Ubuntu
sudo update-grub
# RHEL/Fedora (BIOS)
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# RHEL/Fedora (UEFI)
sudo grub2-mkconfig -o /boot/efi/EFI/<distro>/grub.cfg

On the GRUB menu, there is usually an entry like “Advanced options for …” that lists available kernels.

Permanently setting the default kernel

Instead of choosing manually each boot, you can set a persistent default.

Using GRUB’s saved default

  1. Enable saved default in /etc/default/grub:
text
   GRUB_DEFAULT=saved
   GRUB_SAVEDEFAULT=true
  1. Regenerate GRUB configuration (see above).
  2. After booting with GRUB, use:
bash
   sudo grub-set-default 'Advanced options for Ubuntu>Ubuntu, with Linux 6.8.0-47-generic'

The entry name must match what appears in /boot/grub/grub.cfg. On RHEL/Fedora:

bash
   sudo grub2-set-default 1    # index starting from 0

Using distribution tools

Some distributions provide wrapper tools, e.g.:

These can set default kernels without editing GRUB config manually.

Removing Old Kernels Safely

Kernel management includes cleanup to free disk space (particularly /boot).

When to remove old kernels

Safe practice:

Scenarios for cleanup:

Removing kernels with package manager

bash
# Debian/Ubuntu: removing one specific kernel
sudo apt remove linux-image-6.8.0-25-generic
# RHEL/Fedora
sudo dnf remove kernel-6.7.10-200.fc40.x86_64
# Arch: you normally have only one or few variants (linux, linux-lts)
sudo pacman -R linux          # be careful; ensure another kernel is installed
# openSUSE/RPM-based
sudo zypper remove kernel-default-6.6.0-1.1

Many distributions also have automation:

text
  installonly_limit=3

After removal, regenerate GRUB if required (some tools do this automatically).

Avoiding a broken system

To stay safe:

  1. Verify at least two kernels remain installed.
  2. Never delete linux-image-generic / kernel-core meta‑packages that track current kernel lines unless you know what you’re doing.
  3. Ensure your /boot partition has enough free space for at least:
    • One new kernel image.
    • Its initramfs / initrd.

Check space:

bash
df -h /boot

Kernel Configuration and Parameters (High-Level View)

Deep details of kernel parameters and boot process are covered in their own chapters; here we focus on how kernel management interacts with them.

Boot-time parameters vs runtime tuning

Kernel behavior can be adjusted by:

Kernel management often includes:

Boot parameters via GRUB

Edit /etc/default/grub and modify:

text
GRUB_CMDLINE_LINUX="quiet splash"

Examples of added parameters:

Then regenerate GRUB config. These apply to all kernels booted via that configuration.

Runtime settings via sysctl

Use sysctl to set or query:

bash
sysctl -a                        # list all
sysctl net.ipv4.ip_forward       # show specific
sudo sysctl -w net.ipv4.ip_forward=1

Persistent settings go in /etc/sysctl.conf or /etc/sysctl.d/*.conf. Note:

Distribution-Specific Kernel Management Tools

Some distributions provide extra tools targeted at kernel management.

Debian/Ubuntu

Useful commands:

bash
apt-cache search linux-image
apt policy linux-image-generic

You can “pin” or hold a kernel if necessary:

bash
sudo apt-mark hold linux-image-6.8.0-47-generic

RHEL / Fedora

Examples:

bash
# Show current default kernel
sudo grubby --default-kernel
# Set default to currently running kernel
sudo grubby --set-default /boot/vmlinuz-$(uname -r)

Arch Linux

Arch uses a rolling model; kernel updates come frequently:

Changing from linux to linux-lts:

bash
sudo pacman -S linux-lts
# Then configure bootloader to use linux-lts kernel as default

openSUSE

Configuration like number of kernels to keep is often controlled via /etc/zypp/zypp.conf (look for multiversion options).

Handling Kernel Problems and Rollbacks

A core part of kernel management is being prepared for regressions: new kernels that introduce bugs or unwanted changes.

Symptoms of kernel regressions

Typical signs:

Basic rollback strategy

  1. On boot, in GRUB, select Advanced options and choose an older kernel.
  2. If the older kernel is stable:
    • Boot into it.
    • Remove or downgrade the problematic kernel package.
    • Consider pinning/holding the stable version for a while.
  3. Optionally, report the regression to your distribution with:
    • Precise kernel version.
    • Hardware details (lspci, lsusb).
    • Logs (journalctl -k).

Collecting diagnostic information

When managing kernels, you should be able to gather kernel logs:

bash
# View messages from the current boot
journalctl -k
# View messages from previous boots
journalctl -k -b -1
journalctl -k -b -2

For crashes:

Note: full crash dump management (kexec/kdump) belongs in more advanced administration topics, but you should know that:

Building and Using Custom Kernels (High-Level)

The dedicated “Compiling a custom kernel” section handles details of building; from a management perspective you should know:

Risks and responsibilities

Using custom kernels means:

This approach is usually reserved for:

Coexisting with distribution kernels

A common practice:

This way you can:

Kernel Versioning and Compatibility Considerations

The detailed semantics of kernel versioning are handled elsewhere, but for management purposes:

Recognizing compatibility issues

When managing kernels, you must watch compatibility with:

After a kernel update:

DKMS and automatic module rebuilding

Many distributions use DKMS (Dynamic Kernel Module Support) to rebuild third‑party modules on new kernels:

To list DKMS modules:

bash
dkms status

If a module fails to build for a new kernel, you might:

Summary

Kernel management on Linux involves much more than just knowing the version. In practice you will:

These skills let you treat the kernel as a controlled, upgradable component of your system rather than a mysterious black box.

Views: 80

Comments

Please login to add a comment.

Don't have an account? Register now!