Distro-provided mechanism to clean up old kernels

Imre Gergely gimre at narancs.net
Thu Feb 16 18:23:03 UTC 2012

On 2012-02-16 18:11, Dustin Kirkland wrote:
> I understand that I'm not the first to ask this question.  In fact, I
> see at least 10 similar questions at AskUbuntu.com, and many more
> duplicates:
>  * http://askubuntu.com/search?q=remove+old+kernels
> This week, I received a message from one of our commercial ISP/Cloud
> Hosting Providers, saying:
>>>> Unlike other Linux distributions, Ubuntu does not automatically 
>>>> remove older, unused kernel packages after an update. Over time, 
>>>> this will fill the boot partition and result in future updates 
>>>> failing.
> The email continued, recommending that we clean up old Ubuntu kernels
> using this command:
>   # dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep
> -v "linux-image-$(uname -r)|linux-image-generic" |while read n;do
> apt-get -y remove $n;done
> Truly, I connected to several of my Ubuntu servers, some of which 
> have
> been running for over 4 years, and I manually purged 3GB+ of old
> kernels on some machines!


> So I guess my questions are:
>  1) Surely we're not the only Ubuntu users whose /boot or root
> partition has filled up with age-old kernels, are we?

Nope. I have the same problem. I'm managing a couple of LTSP servers 
(with 10.04 LTS on them) and I saved around 400MB on the compressed 
image file after I purged all the kernels and reinstalled the last one 
(and deleted a lot of generated nbi.img files which remained after 
purging the kernels).
There are also old linux-headers-*  packages which can take up a lot of 

Imre Gergely
gpg --keyserver subkeys.pgp.net --recv-keys 0x34525305

More information about the ubuntu-server mailing list