Distro-provided mechanism to clean up old kernels

Dustin Kirkland kirkland at ubuntu.com
Thu Feb 16 21:34:57 UTC 2012

Hash: SHA512

On Thu, Feb 16, 2012 at 2:31 PM, Kees Cook <kees at ubuntu.com> wrote:
> On Thu, Feb 16, 2012 at 02:21:18PM -0500, Barry Warsaw wrote:
>> On Feb 16, 2012, at 10:11 AM, Dustin Kirkland wrote:
>> >I asked about this in IRC yesterday, and Colin Watson pointed me to
>> >the computer-janitor utility, which is intended to handle this.
>> >Seconds later, Barry Warsaw told me that computer-janitor should die
>> >:-)
>> c-j needs attention, but I'm not particularly motivated to give it what it
>> needs.  There's basic housekeeping, such as that the code for c-j is sprinkled
>> between the update-manager and the computer-janitor packages, and even more
>> important problems such LP: #458872.  What's demotivating though is that in
>> all the discussions we've had about the tool, most people think it's just not
>> user-friendly enough given today's emphasis on software-center.
> FWIW, this is the highly advanced system I use for my auto-updated VMs. It
> keeps the latest 2 kernels:
> OLD=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | \
>        awk '{print "linux-image-" $0}')
> if [ -n "$OLD" ]; then
>    apt-get -qy remove --purge $OLD
> fi
> Be warned, of course, that if you don't reboot often, you can end up
> removing the kernel you're running. :P

Yeah, something like this, perhaps with a uname -r check, to also
exclude the current kernel you're running, which apparently *is* known
to work.

Regarding computer-janitor and the dbus discussion -- I certainly like
the idea of computer-janitor in general, but I think I agree with
Barry that it feels much more like a desktop than a server solution.

I guess what I would like to see is to take perhaps Kees' script as a
starting point, improve upon that logic slightly, and ship it within
Ubuntu as a consistent, supported, recommended mechanism for vacuuming
out unneeded kernels.  Something like 'remove-old-kernels', perhaps
shipping in computer-janitor, or ideally more pervasive.  In order to
be useful, though, we'd need to make that script available to
installed systems via SRU.

Barry, would you be willing to accept a shell script along these
lines, into computer-janitor, if I cleaned it up and proposed a merge
and shepherded it through the SRU process?  Or, is there a better home
we can agree upon?

- --

Dustin Kirkland
Ubuntu Core Developer

Version: GnuPG v1.4.11 (GNU/Linux)


More information about the ubuntu-server mailing list