Maintaining an up-to-date Linux kernel is crucial for security, hardware compatibility, and performance optimization. This guide outlines reliable methods to upgrade the kernel on Ubuntu systems, catering to different use cases and expertise levels.
Security Patches: Mitigate vulnerabilities.
Hardware Support: Enable newer devices/features.
Performance Gains: Benefit from scheduler/IO improvements.
Stability Fixes: Resolve kernel-level bugs.
⚠️ Caution:
Test upgrades in non-production environments first.
Ensure critical drivers (e.g., NVIDIA, ZFS) support the target kernel.
Always have a backup/rollback plan.
Best for: Stable, tested kernels with long-term support (LTS).
Update Package Lists:
sudo apt update && sudo apt full-upgrade -y
Install HWE Kernel (LTS Systems):
For Ubuntu 22.04 LTS:
sudo apt install --install-recommends linux-generic-hwe-22.04
Reboot & Verify:
sudo reboot uname -r # Check kernel version (e.g., 6.5.x)
Best for: Enthusiasts needing cutting-edge features.
Risk: Less tested; potential compatibility issues.
Add Mainline PPA:
sudo add-apt-repository ppa:cappelikan/ppa -y sudo apt update
Install Mainline GUI Tool (Optional):
sudo apt install mainline
Launch via mainline
to select/install kernels graphically.
Or Install via CLI:
sudo apt install linux-image-unsigned-<version>-generic linux-headers-<version>-generic
(Replace
with target kernel, e.g., 6.8.4
)
Best for: Customization or specific debugging needs.
Install Dependencies:
sudo apt install build-essential libncurses-dev bison flex libssl-dev libelf-dev
Download Kernel Source:
Visit kernel.org, download the desired source (e.g., linux-6.8.tar.xz
).
Extract & Configure:
tar -xvf linux-6.8.tar.xz cd linux-6.8 make menuconfig # Use current config: /boot/config-$(uname -r)
Compile & Install:
make -j$(nproc) # Compile using all cores sudo make modules_install # Install modules sudo make install # Install kernel sudo update-initramfs -c -k 6.8.0 # Update initramfs sudo update-grub # Update GRUB sudo reboot
Boot into Previous Kernel:
Hold Shift
during boot to access GRUB → Select older kernel.
Remove Problematic Kernel:
sudo apt purge linux-image-<version>-generic
Check Loaded Kernel: