We recently received the latest Ubuntu LTS, a version that you will surely have through updates. This will surely have caused se fill your hard drive with packages and kernels that are not removed. Especially the kernels that are still there.
If i know it exists the autoremove tool to remove unnecessary packages, but packages are removed, not old kernels, hence the need for this tool. Also in hard drives such as SSDs, the need to free up space is important. Maybe because of all this, dustin kirkland, Canonical worker has created a tool to remove old kernels from our Ubuntu system.
Old kernels can be erased to free up hard disk space
The tool we need is in the byobu package, a package that we find in Ubuntu 16.04, for previous versions and if you cannot install this package, I recommend that you go through the github from the creator where you can get it. Once we have installed the Byoubu package, we have to run the tool and it will take care of removing all the necessary kernels minus the last two, which are the necessary ones. This system is for safety, since in case the last one fails, the user will be able to choose the last one that worked.
Thus, to run the program we will have to open a terminal and write the following:
sudo apt-get install byobu sudo purge-old-kernels
This will do everything we need. If we also want to save some more kernels, the program has several parameters that will allow us to do this, such as the –keep parameter. All these parameters are listed in the package's man page, which you can also see through the synaptic manager.
The truth is that The Kernel is one of the parts of Ubuntu that is most updated and that occupies the most space, that is why if you come from Ubuntu 14.04 or Ubuntu 13.10, it is best to run this tool, you will notice how much space is freed up and the system is also faster. So Why not give it a try?
I think there is an error with the command
sudo:purge-old-kernels:command not found
I use the long command but between sudo and purge there should be no ":", just a space
My Ubuntu 16.04 tells me that the package does not exist:
sudo apt-get install byobu
Reading package list ... Done
Creating dependency tree
Reading the status information ... Done
E: The byobu package could not be located