FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Server Development

 
 
LinkBack Thread Tools
 
Old 02-16-2012, 08:50 PM
Marc Deslauriers
 
Default Distro-provided mechanism to clean up old kernels

On Thu, 2012-02-16 at 15:40 -0500, Barry Warsaw wrote:
> The real question as to the future of c-j is whether it's even the right
> approach to cleaning up your system. If so, then maybe a bit of engineering
> to clean it up, better separate the backend from the dbus, ui, and cli
> interfaces, and package it in a better way would be worth it.

Ideally, something like this should be hooked up to apt, with an
appropriate config option somewhere among the unattended upgrades or
autoremove settings.

Do we keep a successful boot flag for each kernel somewhere? It would be
nice if the tool kept the currently running kernel, and the 3-5 previous
kernels that have successfully booted.

Marc.



--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-16-2012, 09:43 PM
Kees Cook
 
Default Distro-provided mechanism to clean up old kernels

On Thu, Feb 16, 2012 at 03:36:31PM -0600, Dustin Kirkland wrote:
> On Thu, Feb 16, 2012 at 3:08 PM, Craig White <craig.white@ttiltd.com> wrote:
> > this was interesting but I found that I had to NOT use 'head -n -2' but rather 'head -n 2'
>
> You can do 'head -2' or 'head -n2', but not 'head -n -2'. I assumed
> it was a typo ;-)

Hurm? -n -2 is perfectly valid. It shows "all but the N first lines":

-n, --lines=[-]N
print the first N lines instead of the first 10; with the
leading `-', print all but the last N lines of each file


$ seq 1 5 | xargs -n1 | head -2
1
2
$ seq 1 5 | xargs -n1 | head -n 2
1
2
$ seq 1 5 | xargs -n1 | head -n -2
1
2
3

-Kees

--
Kees Cook

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-16-2012, 10:33 PM
Przemek Kulczycki
 
Default Distro-provided mechanism to clean up old kernels

On 16 February 2012 20:21, Barry Warsaw <barry@ubuntu.com> 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.

You should also note that Ubuntu Tweak has its own Janitor tool included.
This tool is quite popular among desktop users.
Regards,
--
# Przemysław Kulczycki
## Jabber/XMPP/Gtalk/Tlen ID: azrael[na]jabster.pl

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 05:23 AM
Martin Pitt
 
Default Distro-provided mechanism to clean up old kernels

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.

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

--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 06:29 AM
Vincent Ladeuil
 
Default Distro-provided mechanism to clean up old kernels

>>>>> Martin Pitt <martin.pitt@ubuntu.com> writes:

<snip/>

> 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.

My own use case here is that I had to work around a bug in newer kernels
by running a very old one for *months*, I don't have the precise number
anymore but I think I had at least 5 or 6 kernels newer than the only
one I could use.

Is there a way to know the last time a kernel was booted and use that as
a criteria to keep it ?

This will allow removing kernels unused for months limiting the risks
that we remove a vital one.

Vincent

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 08:17 AM
Sander Smeenk
 
Default Distro-provided mechanism to clean up old kernels

Quoting Kees Cook (kees@ubuntu.com):

> 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

Clean. I wrote this little perlscript which i hook from APT:
https://8n1.org/raw/8337/e0ec

At my workplace we manage >150 servers for customers, this saved us a
lot of space in backups and on the physical serves. For what it's worth,
i don't think Ubuntu should introduce dbus services just to clean up
kernels.

Ubuntu Server installs are bloated enough as it is.
But that's just my 25 cents.

-Sander.
--
| If you think nobody cares, try missing a couple of payments.
| 4096R/20CC6CD2 - 6D40 1A20 B9AA 87D4 84C7 FBD6 F3A9 9442 20CC 6CD2

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 08:22 AM
Stefan Bader
 
Default Distro-provided mechanism to clean up old kernels

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.

-Stefan
> 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
>


--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 08:42 AM
Pandu Poluan
 
Default Distro-provided mechanism to clean up old kernels

Server guys (me included) will only ask that whatever's the default in grub be kept. That, and maybe 2 latest kernel excluding the default.


Server guys are also (usually) much more aware with what's going on, so for them they would appreciate a tool that will:


* List all kernels (and their baggages) found in /boot


* Protect the current default in grub


* Show which 2 other kernels are recommended/protected


* Provide a way to protect other kernels explicitly


* Delete the useless kernels (and their baggage) automatically.


Rgds,



On Feb 17, 2012 1:25 PM, "Martin Pitt" <martin.pitt@ubuntu.com> 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.



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



--

Martin Pitt * * * * * * * * * * * *| http://www.piware.de

Ubuntu Developer (www.ubuntu.com) *| Debian Developer *(www.debian.org)



--

ubuntu-server mailing list

ubuntu-server@lists.ubuntu.com

https://lists.ubuntu.com/mailman/listinfo/ubuntu-server

More info: https://wiki.ubuntu.com/ServerTeam


--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 09:49 AM
Tim Edwards
 
Default Distro-provided mechanism to clean up old kernels

On Fri, Feb 17, 2012, at 07:23 AM, Martin Pitt wrote:
> 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?

Are you sure about this? I did a test and I don't think that autoremove
removes the linux-headers-*:
$ dpkg -l | awk '/^ii/{print $2}' | grep ^linux
linux-firmware
linux-generic
linux-headers-3.0.0-14
linux-headers-3.0.0-14-generic
linux-headers-3.0.0-15
linux-headers-3.0.0-15-generic
linux-headers-3.0.0-16
linux-headers-3.0.0-16-generic
linux-headers-generic
linux-image-3.0.0-15-generic
linux-image-3.0.0-16-generic
linux-image-generic
linux-libc-dev
linux-sound-base

$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.

I'd like to suggest instead the following modifications to the script
that was posted before:
#!/bin/bash
OLDKERNEL=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | awk
'{print "linux-image-" $0}')
OLDHEADERS=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | sed
's/-generic//g' | awk '{print "linux-headers-" $0}')
if [ -n "$OLDKERNEL" -o -n "$OLDHEADERS" ]; then
sudo apt-get -q remove --purge $OLDKERNEL $OLDHEADERS
fi

(note that this version is not fully automatic as apt will prompt the
user before removing packages)

Tim

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 
Old 02-17-2012, 07:30 PM
Bryce Harrington
 
Default Distro-provided mechanism to clean up old kernels

On Fri, Feb 17, 2012 at 08:29:08AM +0100, Vincent Ladeuil wrote:
> >>>>> Martin Pitt <martin.pitt@ubuntu.com> writes:
>
> <snip/>
>
> > 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.
>
> My own use case here is that I had to work around a bug in newer kernels
> by running a very old one for *months*, I don't have the precise number
> anymore but I think I had at least 5 or 6 kernels newer than the only
> one I could use.

Having 5 or so kernels would also be handy for troubleshooting drm bugs;
once and a while we have to have the user boot earlier kernels to
bracket when a regression started. It's not a huge issue though; we can
always just have them download older kernels. But if they're already on
disk it makes troubleshooting a bit more convenient.

> Is there a way to know the last time a kernel was booted and use that as
> a criteria to keep it ?
>
> This will allow removing kernels unused for months limiting the risks
> that we remove a vital one.

Time of last boot, and/or total number of times booted would be
interesting metrics. For fallback purposes I'd love to hang onto a old
known-good kernel that I'd booted a hundred times, rather than the one
from last week which may well have the same bug I'm trying to get
around. But maybe this is overthinking things. ;-)

Bryce

--
ubuntu-server mailing list
ubuntu-server@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server
More info: https://wiki.ubuntu.com/ServerTeam
 

Thread Tools




All times are GMT. The time now is 07:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ę2007 - 2008, www.linux-archive.org