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.
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.
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
Once this command has completed simply reboot your machine
Your machine should now start faster and you will now be able to update and upgrade
apt-get update && apt-get upgrade && apt-get dist-upgrade
Once complete your machine should be back to booting up quicker and your boot sector back to using minimum space.
A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.