In the Ubuntu environment, we have a number of ways to upgrade the kernel. The Ubuntu desktop version upgrades the kernel as it updates every day, and Ubuntu Server can upgrade the kernel using Unattended-upgrade Automatic Updates, as well as using apt-get or aptitude to simultaneously accommodate the Ubuntu desktop or service Service version.
With the passage of time, the replacement of the old version of the kernel will occupy a certain amount of disk space and cause waste. Each kernel image file and associated module file/header (header file) consumes approximately 200–400 M of disk space, and if the kernel version is upgraded frequently, the waste of the old kernel files on the space will increase rapidly.
You can view all bootable versions of the kernel files using the following command:
ll/boot/
Clean up Ubuntu old Linux kernel files
Before we start cleaning up, please be sure to keep at least two recent kernel versions to ensure that there is one more retreat after the problem.
The kernel image files for Ubuntu mainly include the following types of packages:
linux-image-< version number >: Kernel image files
linux-image-extra-< version number >: Extended kernel Module
linux-headers-< version number >: Kernel header file
1. First look at what version of the kernel the current system has installed:
Dpkg--list | grep linux-imagedpkg--list | grep linux-headers
2. After determining the version to be deleted, we can use the following command to delete:
sudo apt-get purge linux-image-3.19.0-23sudo apt-get purge linux-headers-3.19.0-23
The appeal command deletes the kernel image file and its associated kernel module and header file.
Note: If you have not upgraded to the latest kernel version of the Ubuntu update when removing the old kernel, the system will automatically trigger the upgrade to the latest kernel. Also, after removing the old kernel, the grub configuration is automatically updated and the dependencies are removed from the Grub menu.
3. If the GRUB configuration does not automatically refresh after removing the old kernel, you can manually refresh using the following command:
sudo update-grub2