It’s very easy to lose track of how many times the Linux kernel is updated on your system, and, depending on the amount of space allotted to the /boot partition, you’re likely to come across an error stating that there isn’t enough space to provide updates at some point. You may be confused if you see this message, especially since it isn’t always clear where the lack of space is in the message – and you’ll easily tell yourself that there’s no way your root partition doesn’t have the 100MB of space to perform the update. Instead, it’s the boot partition that is lacking the available space.
Why? Because every time the Linux kernel is updated, the previous kernel is kept on the system as well. You might think it pointless, but it’s actually rather nice – especially if a kernel update creates an issue with something you have installed on the system. You can easily boot into a previous kernel in that situation. The problem is that there is no limit to how many kernels are stored, and so after about ten kernel updates, you’re likely going to be out of space – especially with the default 500MB partition allotment that Ubuntu and its derivatives tend to stick with.
The easiest way, in my opinion, to remove these unnecessary kernel images off of the boot partition to provide space for future updates is using Synaptic Package Manger. Some explanations state using the command line to remove the packages, but the UI of Synaptic works great for this.
The first thing I’d advise to do is look at the images stored on the boot partition. You can do that by entering this into your console:
You’ll see a lot of different files listed, but the most important part of each filename is the version number. Despite the variances in the list of files (abi, config, System, etc.), they should all share the same version numbers in that part of their filenames. The thing I recommend doing is removing all but the last two, which should be the current kernel and the previous one before it. You can check which kernel the system is running with this command:
In my situation, I had the following kernels residing on my system:
So, I’m removing kernels 3.13.0-34 through 3.13.0-44. After opening Synaptic Package Manager, first click on Installed in the left-hand column to filter out all uninstalled packages. Then, search for the first part of the version numbers for the kernels. eg.: 3.13.
Select each package title linux-headers-x.xx that fits within the kernel versions we’re removing, and after you’ve highlighted all of them click the green box next to it and select Mark for Complete Removal. You’ll notice that all of the linux-image-x.xx packages have also turned red and are selected for removal. Simply hit Apply at the top and confirm with the popup for the packages to be removed and Synaptic will do the rest. It should take only a few seconds, but less than a minute in any case.
While you’re in Synaptic, you can also remove any residual configurations by selecting Not installed (residual config) in the left-pane and removing any packages listed there as well. This will clear up any configurations left by packages that have been removed from the system – freeing up wasted space.