[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Kernel upgraded two or three times since install



John Vestrum wrote:
> Mark Panen wrote:
> > I noticed my kernel has been upgraded two or three times but i am still
> > sitting on the original:
> 
> ...  The typical advice to use dpkg/apt-query/aptitude only tells
> half the story - those tools only know which kernel is installed,
> not what is running. I finally found what I was looking for in
> /proc/version.
> 
> $ cat /proc/version
> Linux version 2.6.32-5-amd64 (Debian 2.6.32-38) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Oct 3 03:59:20 UTC 2011
> 
> Based on that I wrote a shell script to tell me if a machine needs a
> reboot, the heart of which is:

I do something similar and so took an interest in your script.  :-)

> RUNNINGKERNEL=`awk '{print $5}' /proc/version | tr -d ')'`
> INSTALLEDKERNEL=`dpkg-query --show --showformat='${Version}\n' linux-base`
> ...
> At least this works on amd64 Squeeze.

Note that won't work after Squeeze.  In Squeeze works.  In Wheezy/Sid:

  $ dpkg-query --show --showformat='${Version}\n' linux-base
  3.3

A note that you will need something different between now and then.
There is plenty of time however.

You might consider using 'linux-image-$PKGARCH' instead.  Where
$PKGARCH is created either depending upon $(uname -m) output or
$(dpkg --print-architecture) output created using /proc/version
output.  I prefer to extract it from /proc/version and then it works
on subarchitectures.

  $ uname -m
  i586

  $ cat /proc/version
  Linux version 2.6.32-5-486 (Debian 2.6.32-38) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Mon Oct 3 03:34:28 UTC 2011

  $ perl -lne '$_ =~ m/Linux version \S+-(\S+)/ && print $1;' /proc/version
  486

Unfortunately linux-image-$PKGARCH isn't installed by the Squeeze
debian-installer and therefore isn't available unless explicitly
installed.  You will have to deal with that problem first.  I would
install it and then it would be there.  It is one of the packages that
I routinely install manually after a fresh installation.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: