Tips to get Rid of Unused Kernel Images on Ubuntu

Tips to get Rid of Unused Kernel Images on Ubuntu

When you are working in an Ubuntu environment, you will find various ways of upgrading the kernel. The Software Updater helps you to update the kernel on daily basis. The unattended- upgrades package allows the upgrading automatically and this is an integral part of the security updates on Ubuntu server. You can even manually upgrade it using the aptitude command or apt-get.

Due to this continuous upgrade, you are sure to face the problem of disk space management. The upgrade is responsible for the accumulation of unused and old kernel images. Almost 200-400 MB of space is used by the kernel images along with the related modules.

So the disk space is wasted like anything and that is why you really need to get rid of the unused images to overcome the space constraint.

How to Get Rid of Old Kernel Images?

Kernel images can be removed with the help of many processes. Two of them are:

Apt-get

Before cleaning the images make sure that at least two images are intact. In Ubuntu various kernel image packages are installed.You have to use the command “$sudo apt-get purge Linux image- 3.19.0-15” to remove a version 3.19.0-15.The moment you remove an old kernel, the latest Linux kernel image will be installed whether you have upgraded it or not.

GRUB will also be triggered and will get automatically updated. It will also remove the old GRUB entry from GRUB menu. You can also remove multiple kernel images at one go using the shell expansion command.

Purge –old Kernels

You can also use a more user –friendly command-line tool known as purge-old –kernels. It is a part of a package called bikeshed. This is a random collection of many useful tools.

With the help of the purge-old-kernel, you can delete a configurable number of header files and old kernel images. To remove all and keeping the last three images you need to run “$sudo purge-old-kernels—keep 3”.

Use of all these tools can be learnt in depth if you take up RHCE training.