So I’m logging into my Ubuntu 12.04 server today and I get the following message:

/boot is using 96.4% of 249MB

I really didn’t think too much of it, except that gosh, that’s almost full.  Oh well.  I went on with my usual maintenance which includes installing new packages, and doing a dist-upgrade (which installs a new set of linux headers and a new kernel).  Unfortunately, this time, I got a bunch of errors when trying to install the new kernel and headers.  Presumably because my /boot partition was already too full.

After some poking around I discovered this forum post which lead me to the resolution.  What was happening was that every time I had done a dist-upgrade, to upgrade the Linux kernel, Ubuntu wasn’t removing the old kernel.  Ubuntu studiously archives those older kernels so that you can boot into them if anything were to go bad when booting into your new kernel.  So I ended up having a boatload of older kernels archived which caused my partition to fill up and prevented me from adding any new kernels.  Lucky for me, the internet knows how to fix this.

First SSH into your Ubuntu server and determine what kernel you are currently running

uname -r

To which it responds:

3.2.0-36-generic

Then, we need to get a list of kernels that you currently have installed.

sudo dpkg --list 'linux-image*'

This is going to spit out something that looks like this:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
un linux-image <none> (no description available)
un linux-image-3. <none> (no description available)
ii linux-image-3. 3.2.0-20.33 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-24.39 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-25.40 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-26.41 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-27.43 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-31.50 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-32.51 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-33.52 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-35.55 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-3. 3.2.0-36.57 Linux kernel image for version 3.2.0 on 64 b
ii linux-image-se 3.2.0.36.43 Linux kernel image on Server Equipment.

You’ll now want to walk down the list and begin removing them one by one.  So for each of the kernels (Important Note: DO NOT REMOVE YOUR CURRENT KERNEL) do this:

sudo apt-get remove linux-image-3.2.0-20-generic

After running this command you’ll be asked if you want to proceed (Y/n), which you’ll probably want to respond with a resounding ‘Y’.  Repeat this until you have removed all but the current kernel and perhaps even the previous kernel for backup purposes.  I removed all the way up through kernel 3.2.0-33, opting to keep 35 just in case.

And that’s it.  All is right with the world once again.

Was this post helpful?
  • Thanks 
  • Sort-of 
  • Not Helpful 

Leave a Reply

Your email address will not be published. Required fields are marked *