Change Linux Kernel #
List Current Kernel #
# List current loaded Kernel version
uname -r
# Shell Output
5.15.0-76-generic
# List current loaded Kernel version: Detailed
cat /proc/version_signature
# Shell Output
Ubuntu 5.15.0-76.83-generic 5.15.99
List Installed Kernels #
Grub Configuration File #
This file contains entries for all the available boot options, including different kernel versions.
# List bootable Kernels from Grub
grep 'menuentry ' /boot/grub/grub.cfg | cut -d "'" -f2
# Shell Output
Ubuntu
Ubuntu, with Linux 5.15.0-76-generic
Ubuntu, with Linux 5.15.0-76-generic (recovery mode)
Ubuntu, with Linux 5.15.0-75-generic
Ubuntu, with Linux 5.15.0-75-generic (recovery mode)
Package Manager #
# Package Manager: List available Kernels
dpkg --list | grep linux-image
# shell Output
rc linux-image-5.15.0-53-generic 5.15.0-53.59 amd64 Signed kernel image generic
rc linux-image-5.15.0-67-generic 5.15.0-67.74 amd64 Signed kernel image generic
rc linux-image-5.15.0-71-generic 5.15.0-71.78 amd64 Signed kernel image generic
rc linux-image-5.15.0-72-generic 5.15.0-72.79 amd64 Signed kernel image generic
ii linux-image-5.15.0-75-generic 5.15.0-75.82 amd64 Signed kernel image generic
ii linux-image-5.15.0-76-generic 5.15.0-76.83 amd64 Signed kernel image generic
ii linux-image-generic 5.15.0.76.74 amd64 Generic Linux kernel image
rc
Kernel is removes, their configuration files remainii
Currently installed and available to boot
Switch Kernel #
Install newer Kernel #
Available Ubuntu Kernels:
https://kernel.ubuntu.com/~kernel-ppa/mainline/
# Download the required Kernel and dependencies
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.3.13/amd64/linux-headers-6.3.13-060313-generic_6.3.13-060313.202307111431_amd64.deb &&
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.3.13/amd64/linux-headers-6.3.13-060313_6.3.13-060313.202307111431_all.deb &&
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.3.13/amd64/linux-image-unsigned-6.3.13-060313-generic_6.3.13-060313.202307111431_amd64.deb &&
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.3.13/amd64/linux-modules-6.3.13-060313-generic_6.3.13-060313.202307111431_amd64.deb
# Install the Kernel and dependencies
sudo dpkg -i linux-headers-6.3.13*.deb linux-image-unsigned-6.3.13*.deb linux-modules-6.3.13*.deb
# Reboot the server to complete
sudo reboot
# Check Kernel Version after reboot
uname -r
# Shell Output:
6.3.13-060313-generic
The installation process updates GRUB with the new kernel as the default choice. The server will automatically boot into the new kernel.
Select Kernel with Grub Menu #
Let’s boot back into the old Kernel and remove the newly installed kernel.
# Reboot the system
reboot
# Open Grub Menu: Press after Bios
`Shift` or `Esc`
- Open Advanced options for Ubuntu
- Select / boot into the previous Kernel
Extend Grub Menu display #
If you want to automatically show the Grub Boot Menu without pressing “Shift”, proceed as follows:
# Open Grub Configuration File
sudo vi /etc/default/grub
# Shell Output
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
# Uncomment the following line
GRUB_HIDDEN_TIMEOUT=0 # or
GRUB_TIMEOUT_STYLE=hidden
# Define seconds to display Grub Menu before it boots the default selection
GRUB_TIMEOUT=5
# Or set to wait indefinitely
GRUB_TIMEOUT=-1
# Update Grub
sudo update-grub
Remove new Kernel #
# Remove the 6.3 Kernel
sudo apt-get remove 'linux-image-6.3*' 'linux-headers-6.3*' 'linux-modules-6.3*'
# Update Grub
sudo update-grub
# Reboot
sudo reboot
Kernels Modules #
# List all Kernels available on the system (Modules are in the subfolders)
ls /lib/modules
# Shell Output
5.15.0-53-generic 5.15.0-67-generic 5.15.0-71-generic 5.15.0-72-generic 5.15.0-75-generic 5.15.0-76-generic
# Remove old Kernels
apt autoremove
Add & Remove Kernels Modules #
# List status of modules in the Kernel
losmod
# Add Module to Kernel (till reboot): For example bluetooth
modprobe bluetooth
# Remove Module
modprobe -r bluetooth
# Add Module to Kernel: Automatic at system boot
vi /etc/modules