Remove All Unused Linux Kernel Headers, Images and Modules from ubuntu boot

If you are constantly updating your linux installation you may find over time that your boot partition may be running out of space and if list the contents of your boot partition you may find several versions of the same files i.e. kernel versions listed.

Shell

It’s always a good idea to Remove All Unused Linux Kernel Headers, Images and Modules unless you specifically need them . The unused  Linux Kernel Headers, Images and Modules could cause a few issues going forward, potentially your machine could run out of space in the boot partition, and it may not be able to carry out updates in future.

Fortunately there is a simple way to fix this. Running the following command , will remove all older versions and only leave the latest kernel version. This will free up space in your boot sector by removing unused and unnecessary files.

Shell

Once this command has completed simply reboot your machine

Shell

Your machine should now start faster and you will now be able to update and upgrade

Shell

Once complete your machine should be back to booting up quicker and your boot sector back to using minimum space.

Advice

I have developed a convenient bash file to update your ubuntu and remove all unused Linux kernel headers, images and module

How to execute a BASH script

Gary Woodfine

Technical Director at Denizon
Gary is Technical Director at Denizon, an independent software vendor specialising in IoT, Field Service and associated managed services,enabling customers to be efficient, productive, secure and scalable in a way which helps them address and reduce their ecological impact.

Denizon's product line successfully integrate IoT, Artificial Intelligence and Blockchain technology to enable efficient, productive, secure and scalable solutions to help organisations address increasing energy demands, ecological impact and Health & Safety concerns of their staff.

Latest posts by Gary Woodfine (see all)