Debian

How to Remove Unused Old Kernel Images on Debian

Removing old kernel images on Linux systems, such as Debian is important because they take up a lot of system space, which eventually impacts the system performance. It makes the system unstable and slows down its performance. Removing those kernel images from the system will free up disk space and help you increase the system’s performance.

This article presents a detailed guide to remove unused old kernel images from the Debian system.

Remove Unused Old Kernel Images on Debian

To remove the unused old kernel images on Debian, follow the below-mentioned steps:

Step 1: Checking the Currently Used Kernel

To remove the old kernel, you must be logged into the new kernel, and to verify that, display the kernel you are using by running any the following command:

uname -a

Step 2: Listing all Installed Kernels

Now to list all the installed kernels, run the below-mentioned command:

dpkg --list | egrep -i --color 'linux-image|linux-headers'

In the output, you will get the list of all the kernels, as shown in the image below:

Note: You might find some very old kernel-images in the list, as my system is updated so I only have new 5.10 version kernel images.

Step 3: Removing Unused Kernel Images

Once you have gotten the list of all installed kernel images, now you can remove all the kernel images that you think you don’t need any longer, and for that use the below-written command:

sudo apt-get --purge remove <kernel image name>

For example:

sudo apt-get --purge remove linux-image-5.10.0-21-686-pae

Step 4: Auto Removing

In latest Linux systems, usually the unused packages are marked for un-installation, so to automatically clean the Debian system it’s better to remove the unused kernel images by running the below-written command:

sudo apt --purge autoremove

After following all of the above-mentioned steps, your Debian system will have more space on the disk and all the unused packages and kernel images will get removed from the system. You can reboot the system for a fresh start if you want but that is not mandatory.

Conclusion

To remove the old unused kernel images on Debian, firstly list all the installed kernels after which you can remove the old kernel images that are no longer required by running the “apt-get purge remove” command along with the name of the kernel image. Finally, run the auto-remove command to clean the system from unused packages and to free up the space on the system’s disk.

About the author

Zahra Zamir

An Electronics graduate who loves to learn and share the knowledge, my passion for my field has helped me grasp complex electronics concepts and now I am here to share them with others.