Distro-provided mechanism to clean up old kernels

Stefan Bader stefan.bader at canonical.com
Fri Feb 17 09:22:13 UTC 2012

On 17.02.2012 07:23, Martin Pitt wrote:
> Dustin Kirkland [2012-02-16 10:11 -0600]:
>> I don't want to go into all the ways and reasons that the one-liner
>> above is sub-optimal or even evil, but I would like to call attention
>> to the generic problem and suggest that as a distribution, we provide
>> a supported and recommended utility to handle this.
> I agree. Especially since we switched to a two-weeks kernel update
> rhythm where almost every update in the most recent stable and LTS
> releases breaks ABI, kernels pile up like mad.
>>  1) Surely we're not the only Ubuntu users whose /boot or root
>> partition has filled up with age-old kernels, are we?
> Certainly not. I ran into several "home support" cases where Ubuntu
> started acting strangely because the root partition filled up, and we
> removed about 15 old kernels.
>>  2) Is computer-janitor here to stay, or to be abandoned in favor of
>> something else?
>>  3) Can we expect computer-janitor to work on command-line only
>> environments (Ubuntu servers) too?  If so, can we get SRUs out so that
>> it works on older distributions?
> TBH, I don't think c-j or any other manual tool is the right answer
> here. While it's nice to have it, it doesn't feel right that Ubuntu
> "automatically" introduces the problem, but not automatically clean
> up after itself.
>>  4) Can we, as a distro, provide and recommend a utility to clean out
>> specifically old kernels (perhaps aside from cleaning up userspace
>> cruft a la computer-janitor)?
> I think it'd be best if update-manager would auto-remove all kernel
> packages except the most recent two or three during dist-upgrade. This
> needs to be specified carefully of course, as people might explicitly
> run a kernel from the previous distro release. So perhaps some
> clevernes like if you install linux-image-3.2.0-N-generic, delete all
> kernels up to linux-image-3.2.0-(N-2)-generic. 

While agreeing that it would be quite helpful and seems appropriate to have the
cleanup automatic, there is a slight potential pitfall (or two). There are
various flavours of kernels and people may or may not deliberately have those
installed in parallel. Also various releases had sometimes a changing set of
depending packages. For a while this should be only linux-backports-modules
(there had been linux-ubuntu-modules and linux-restricted-modules). Though this
is not so much of a problem.
>From a pattern matching point of view the generic-pae kernels are a bit of a
pain as they tend to ruin the "use the last part of a split by "-" for the flavor".
But anyway, I think the main issue is the various flavours, so a cleanup that is
automatic should retain the last three of each, even though this may tend to
leave more kernels around.

> linux-headers-* is already covered by apt-get autoremove, which is
> good. Perhaps we can mark older kernels as auto-removable as well, so
> that without any other tools you at least have one command to clean
> them up all?
> For servers it'd be even better if apt-get dist-upgrade would do the
> cleanup itself, of course. But we have fewer places to hook into the
> logic than in update-manager, so this might be tricky.
> Martin

More information about the ubuntu-server mailing list