Tag: Insufficient Space

Properly Cleaning Up /boot Partition

This is a follow-up post to a post I made earlier today: Cleaning Up /boot Partition.

I won’t say that the steps in that post aren’t going to help clear up space, but it certainly didn’t do the trick for me. I still had a piled up /boot partition loaded with the kernel images. I can’t explain why, but completely removing them via Synaptic apparently didn’t completely remove them. So, it appears this method is more effective.

Search for installed packages named linux-image* to see the kernels on the machine:

dpkg -l linux-image*

Like before, you can find the current kernel using this command:

uname -r

I recommend keeping the current and its previous kernel, but that choice is yours. Either way, you do not want to remove the current kernel! Using the same example from the previous post, I’ll change the step to remove the same kernel images but using this method.

sudo apt-get remove linux-image-{34,35,36,37,39,40,43,44}-generic

Then, remove dependencies.

sudo apt-get autoremove

 

Cleaning Up /boot Partition

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:

ls /boot/

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:

uname -r

In my situation, I had the following kernels residing on my system:

3.13.0-34-generic
3.13.0-35-generic
3.13.0-36-generic
3.13.0-37-generic
3.13.0-39-generic
3.13.0-40-generic
3.13.0-43-generic
3.13.0-44-generic
3.13.0-45-generic
3.13.0-46-generic

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.