To verify that an Ubuntu upgrade successfully installed the new kernel, examine the /boot directory for files matching the current version string. Use commands like
ls /boot/vmlinuz-* or
uname -r to confirm the active kernel matches the latest package available in your repositories. This ensures your system is not booting into an outdated or corrupted kernel image from a previous installation.
Locating Kernel Files in the Boot Partition
The
/boot partition contains the essential files required to start the Linux operating system, including the initial RAM filesystem (
initrd.img) and the compressed kernel images (
vmlinuz). When you perform a standard distribution upgrade using
apt, the package manager downloads the new kernel headers and modules but does not always automatically update the bootloader configuration if errors occur. Therefore, manually inspecting this directory is a critical step in validating the integrity of your upgrade process.
You can list all kernel images currently present on your disk by running the following command in the terminal:
ls -lh /boot/vmlinuz-*
This command provides a human-readable list of file sizes and modification dates. The most recently modified file is typically the one installed during your last upgrade session. If you see multiple versions listed, it indicates that older kernels are retained on the system, which is normal behavior designed to allow rollback in case the new kernel fails to boot. However, you must ensure that the filename corresponds exactly to the version number reported by your package manager as the installed candidate.
Distinguishing Between Active and Old Kernels
While listing files shows what is physically stored on the disk, it does not tell you which one is currently running. To determine the active kernel, use the
uname utility. The command
uname -r prints the release string of the currently executing kernel. Compare this output with the filenames found in
/boot. If they do not match, your system may be booting into an old kernel while the new one sits idle in the
/boot directory, or vice versa, indicating a potential bootloader misconfiguration.
For a more detailed view of the kernel parameters and build information, you can check the contents of
/proc/version. This virtual file provides the exact compilation timestamp and compiler version used for the running kernel, offering another layer of verification against the packages listed in
dpkg.
Verifying Package Installation Status
Checking the filesystem is only half the battle; you must also verify that the Debian package database reflects the correct state. The Linux kernel is distributed as a set of packages, primarily
linux-image-generic or
linux-image-unsigned-generic depending on your Ubuntu version and security requirements. You can query the status of these packages using
dpkg.
Run the following command to see the installed version of the generic kernel image:
dpkg -l | grep linux-image
Look for lines starting with
ii, which indicates a successfully installed package. The version number in the third column should match the kernel version you expect after the upgrade. If you see
rc instead of
ii, the package has been removed but its configuration files remain, which might explain why old kernel files persist in
/boot even though the package is no longer considered "installed" by the package manager.
It is important to note that sometimes the
linux-image-generic package acts as a meta-package. It depends on a specific versioned kernel, such as
linux-image-5.15.0-xx-generic. Upgrading the meta-package triggers the installation of the newest versioned kernel. If your upgrade failed midway, the meta-package might point to a newer version than what was actually unpacked into
/boot. In such cases,
apt-get install --reinstall linux-image-generic can force the system to re-evaluate dependencies and pull down any missing components.
Handling Multiple Kernel Versions
Ubuntu retains several old kernel versions by default to ensure system stability. This is managed by the
auto-remove feature of APT. If you have performed many upgrades, your
/boot partition may contain dozens of kernel files. While this is safe, it consumes disk space. You can clean up unused kernels using
apt autoremove, but you must be cautious. Never remove the currently running kernel or the one specified in your bootloader configuration unless you have a verified fallback option.
Before cleaning, always identify the running kernel using
uname -r. Then, you can safely remove older versions that are no longer needed. For example, if you are running 5.15.0-90 and want to keep only the two most recent minor versions, you can specify the older ones for removal. However, automated cleanup scripts often handle this gracefully if configured correctly via
/etc/apt/apt.conf.d/99autoconfigure or similar APT configurations.
If you encounter issues where the wrong kernel is being booted despite the correct files being in
/boot, you may need to update the GRUB configuration manually. Running
update-grub scans the
/boot directory and regenerates the
/boot/grub/grub.cfg file. This ensures that the bootloader menu lists all available kernels and sets the correct default entry based on your system's preferences.
For deeper insights into how these initial ramdisks load modules at startup, which directly affects which kernel features are available upon boot, you might find the guide on
Understanding the Loading of Modules by initramfs in Linux helpful. Additionally, if your upgrade process encountered dependency conflicts that prevented the kernel from installing properly, reviewing strategies for
Unable to Access Distro During sudo apt-get dist-upgrade on Dual Boot Laptop could resolve underlying package manager corruption issues.
Frequently Asked Questions
Why do I see multiple vmlinuz files in /boot?
Ubuntu keeps old kernel versions to allow you to boot into them if the new one fails. This is a safety feature known as kernel retention. You can safely ignore them as long as the most recent one matches your expected version and is selected in GRUB.
How do I know if my upgrade actually finished?
Check the exit code of your last apt command and run
dpkg -l | grep linux-image. If the status is
ii and the version matches the one in
/boot, the upgrade was successful. If you see errors or mismatched versions, the process likely interrupted.
Can I delete old kernel files manually?
Yes, but it is safer to use
apt autoremove or
apt purge to remove the associated packages. Manually deleting files from
/boot leaves orphaned entries in the package database and GRUB configuration, which can cause confusion during future updates.
What if uname -r shows an old kernel but /boot has a new one?
This usually means the bootloader did not update its configuration file. Run
sudo update-grub to rescan
/boot and update the GRUB menu. After rebooting, the system should load the newest kernel image found in the directory.
Is it safe to remove all old kernels?
It is generally safe to remove kernels older than the two most recent major versions. However, always keep at least one previous working kernel as a fallback. Removing the currently running kernel will not affect the system until you reboot, at which point it may fail to boot if no other valid kernel is present.