6

Let's say I have just done an aptitude safe-upgrade on a Debian system, but I was not paying attention so I did not notice if the kernel was updated or not.

How can I now determine if there was a kernel upgrade and a reboot is in order?

user35042
  • 2,711

4 Answers4

7

Compare the running kernel (uname -a) to the files in /boot and see if there is a newer version.

Sven
  • 99,533
  • 15
  • 182
  • 228
2

Aptitude logs to /var/log/aptitude and apt-get logs to /var/log/dpkg.log. If you've installed a new kernel the installation of the package should be recorded in one or both of those log files.

1

This is a good clue:

cat /var/run/reboot-required*; uname -a | awk '{print "linux-image-"$3}';

If the top version is higher than the bottom version then you likely have an updated kernel (and will have to reboot to activate it).

This script uses apt to get a bit more definitive:

#!/usr/bin/env bash

2021062101

Read currently operating kernel

uname -a | awk '{print "linux-headers-" $3}' > /tmp/kernelversions_currentoperating_kernel.txt currentoperating_kernel=cat /tmp/kernelversions_currentoperating_kernel.txt

Read latest installed kernel

apt list --installed 2> /dev/null | grep linux-headers | grep amd64 | grep -v linux-headers-amd64 | tail -1 | aw k -F/ '{print $1}' > /tmp/kernelversions_latestinstalled_kernel.txt latestinstalled_kernel=cat /tmp/kernelversions_latestinstalled_kernel.txt

Read latest available kernel

apt list 2> /dev/null | grep linux-headers | grep amd64 | grep -v .bpo | grep -v "-all" | grep -v "-cloud" | g rep -v "-rt" | grep -v linux-headers-amd64 | tail -1 | awk -F/ '{print $1}' > /tmp/kernelversions_latestavaila ble_kernel.txt latestavailable_kernel=cat /tmp/kernelversions_latestavailable_kernel.txt

Print kernel versions

echo "CURRENTLY OPERATING KERNEL: " $currentoperating_kernel echo "LATEST INSTALLED KERNEL: " $latestinstalled_kernel echo "LATEST AVAILABLE KERNEL: " $latestavailable_kernel echo echo

Delete temporary files

rm /tmp/kernelversions*

Check the LATEST INSTALLED KERNEL. If it is a higher number than CURRENTLY OPERATING KERNEL, then new kernel was installed, but you'll need to reboot to activate it.

I wrote it to exclude cloud and rt kernel versions. You might need to modify some of the grep statements if you use those.

1

Check menuentry entries in your /boot/grub/grub.conf

check the time stamp of the kernel/vmlinuz* , grub.conf ... and see if it was recently updated.

Look at your /var/log/audit/audit.log and search for any file modifications in /boot

...I can go on and on ... -:)

Daniel t.
  • 9,424