[7864] in Release_7.7_team

home help back first fref pref prev next nref lref last post

Re: recovery hook to clean up /boot

daemon@ATHENA.MIT.EDU (Jonathon Weiss)
Fri Dec 21 14:40:54 2012

Message-Id: <201212211940.qBLJekjQ021137@outgoing.mit.edu>
To: Jonathan Reed <jdreed@MIT.EDU>
cc: release-team@MIT.EDU
In-reply-to: <alpine.DEB.2.02.1212181234020.23665@infinite-loop.mit.edu>
Date: Fri, 21 Dec 2012 14:40:45 -0500
From: Jonathon Weiss <jweiss@MIT.EDU>


Several comments:


1) I think your mail client may have folded the first line or two.

2) When I tried this on my machine, it prompted for confirmation before
removing stuff.  I'm not sure what it would do if it were run without a
tty, nor amI sure my workstation isn't a special snowflake in this case.

3) it makes no attempt to remove the corresponding linux-headers-<vers>
ot linux-headers-<vers>-generic.  These are certainly less critical in
that they don't dump stuff on /boot, but seem like they should probably
be handled too.

4) It's itempotency is wacky, since the rmoved images are still listed
as having config files around so they still get picked up by the
dpkg-query, though the later removal doen't remove the packages because
they are already gone.  So I don't think any real harm is cause here,
but it isn't exactly pretty.

-- 

	Jonathon





Jonathan Reed <jdreed@MIT.EDU> wrote:

> We apaprently filled up /boot on a bunch of cluster workstations, and
> users are helpfully getting notified about this.  We need to clean it
> up.
> 
> I propose the following recovery hook.  (Cluster workstations should
> only have linux-image-generic).   I plan to push this out on the 26th
> unless people object.  (I'm not here on the 21st, and, uh, that's a
> bad day to push out additional things)
> 
> Silence will be interpreted as approval.
> 
> #!/bin/bash
> 
> kernels=$(dpkg-query -W -f '${Package}\n' linux-image-\*-generic | sed
> -e 
> 's/^linux-image-//' | sort -V)
> numkernels=$(echo "$kernels" | wc -l)
> if [ $numkernels -le 2 ]; then
>     exit 0
> fi
> toremove=$(echo "$kernels" | head -$(($numkernels-2)))
> kpkgs=
> for k in $toremove; do
>     if [ "$(uname -r)" != "$k" ]; then
> 	kpkgs="$kpkgs linux-image-$k"
>     fi
> done
> if apt-get -s remove $kpkgs; then
>     apt-get remove $kpkgs
> fi
> 
> 

home help back first fref pref prev next nref lref last post