From time to time Ubuntu updates the GRUB menu lists a lot of previous Linux kernels and eats a lot of hard-disk space. In this article, we will discuss how we can remove old and unused kernels from our system.
- Check the kernel currently in use.
- List all the kernels installed.
- Remove the kernel parts.
- Update the GRUB configuration.
Check the kernel currently in use.
uname -r
List all the kernels installed.
dpkg --list | grep linux-image dpkg --list | grep linux-headers dpkg --list | grep linux-modules
Remove the kernel and it’s parts.
For example, I will remove kernel 4.15.0-135 and it’s all components.
WARNING! Don’t forget to change the version number as requires for your needs.
apt-get purge linux-headers-4.15.0-135-generic apt-get purge linux-image-4.15.0-135-generic apt-get purge linux-image-extra-4.15.0-135-generic apt-get purge linux-modules-4.15.0-135-generic apt-get purge linux-modules-extra-4.15.0-135-generic
Update the GRUB configuration.
sudo update-grub2
Reboot
reboot
Test Environment
Ubuntu 20.04 LTS (Focal Fossa)
VMware Workstation 15.1.0
The post [How To] Remove Old and Unused Kernels appeared first on Linux/Unix Tutorials and Configuration..