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

Re: Kernel upgraded two or three times since install



On 08/10/11 12:36, Mark Panen wrote:
> Hi,
> 
> I noticed my kernel has been upgraded two or three times but i am still
> sitting on the original:
> 
> "uname -r
> 2.6.32-5-amd64"
> 

Sorry for the belated reply, but having recently switched from another distro this bothered me as well. 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:

RUNNINGKERNEL=`awk '{print $5}' /proc/version | tr -d ')'`
INSTALLEDKERNEL=`dpkg-query --show --showformat='${Version}\n' linux-base`
if [ "$INSTALLEDKERNEL" != "$RUNNINGKERNEL" ]; then
  echo "Running kernel (version $RUNNINGKERNEL) not the same as latest installed kernel (version $INSTALLEDKERNEL)."
fi

At least this works on amd64 Squeeze.

-- 
John Vestrum


Reply to: