Instructions on how to handle kernel upgrades

Scott Dier dieman at ringworld.org
Sun Sep 5 22:07:37 CDT 2004


Matt Zimmerman wrote:
> They certainly don't; for one, we need to ensure that the currently running
> kernel is not removed.  Currently, the kernel packages do this with a scary,

I run this script at boot on my machines at work.  Feel free to consider 
it in the public domain. (its not like its non-trivial to write or anything)

It's a quick 5 minute perl hack, but it works.

-- 
Scott Dier <dieman at ringworld.org> KC0OBS http://www.ringworld.org/

"Right now we've been presented with an option that says cars now,
transit later -- maybe. That's not good enough."
   -- Minneapolis Mayor R.T. Rybak.
-------------- next part --------------
#!/usr/bin/perl

# current kernel rev
my $currentkernel=`uname -r | cut -f1 -d-`;

# find out installed kernels
my @q = split("\n",`dpkg --get-selections | grep "^kernel-image" | cut -f1 | cut -f3 -d- | sort | uniq`);

my @p;
# sort kernel list
@i = sort {$a <=> $b} @i;

# figure out where in list is current kernel rev

chomp($currentkernel);
my $i;
foreach $i (@q) { 
  if ($i lt $currentkernel) {
    push (@p,$i);
  }
}

foreach $i (@p) {
  my $cmd = ('/bin/sh -c "apt-get -yf remove kernel-.\*'.$i.'.\* umncs-kernel-2.4-386+ 1> /dev/null 2>&1 "');
  system($cmd);
}

system('/bin/sh -c "update-grub 1> /dev/null 2>&1 "');


More information about the sounder mailing list