Things have changed since this post.

It now seems that Ubuntu (at least on 16.04) will stick old kernels for autoremote: you can just sudo apt autoremove to ditch them.

You can see how apt's behaviour is configured in /etc/kernel/postinst.d/apt-auto-removal.

Did a little quick maintenance to my Ubuntu install1 today.

First, I'd noticed that the boot partition was starting to get a little full, meaning that cleaning out old kernel images was overdue. If it gets completely full, you won't be able to upgrade to newer kernel versions.

This is a fairly simple way from the command line; I'll summarise it here.

Check which kernel is currently in use:

uname -r

Do not remove the kernel image that uname returns!

List the other kernels that are installed:

dpkg --list | grep linux-image

You'll see a list that includes the kernel image in use, along with others that aren't. These are safe to remove.

To remove a kernel image, not the one listed from the uname command:

sudo apt-get purge linux-image-x.x.x.x-generic

I've seen it recommended that you keep one or two older images installed in case you need to revert to an older version for any reason, which seems sensible.

You can also remove the corresponding kernel headers too:

sudo apt-get purge linux-headers-x.x.x.x-generic

Second, I'd read a couple of days ago that Ubuntu 14.04 LTS is going to get TRIM support. If you use a solid state drive, TRIM2 is a useful feature that stops the performance of your drive degrading over time.

Great, but hang on, 12.04 LTS never did?

Hmm, better fix that. If you're using an unencrypted file system, then running fstrim on the relevant partitions manually or setting up a cron job to do so isn't too difficult. If you're using a dm-crypt encrypted file system as I am, it's not quite as straightforward. It's still only a two minute job, but it's not quite as obvious what you need to do to get this working. There's a nice guide here that explains each step; you enable TRIM for both dm-crypt itself and the Logical Volume Manager, and then create a cron job that TRIMs the drive weekly.

Before choosing to do this, note that enabling TRIM with dm-crypt can be a security risk. There are potential issues in terms of leaking file system information, which may be a concern if you have hidden volumes.

  1. Incidentally, why have I not got some nice Ubuntu logo here to make this post look nicer? Incidents like this aren't exactly encouraging, even if later admission of mistakes are madeā€¦ 

  2. Reading "TRIM" so many times just meant I had to listen to this while writing.