How-Tos

How-To: Find Linux Boxes Still Running an Old Kernel After You Patched

Leave a comment

Bugs like NoisyTCP live in the kernel, and installing the update isn’t the same as running it. Until you reboot, the old kernel is still in charge. Here’s how I check my own boxes.

1. Compare the running kernel with the installed one

uname -r                      # what's running now
ls /boot | grep vmlinuz       # what's installed

If the newest file in /boot is newer than uname -r, you still need a reboot.

2. Ask the distro

# Debian/Ubuntu
cat /var/run/reboot-required 2>/dev/null
# Fedora/RHEL family
sudo dnf needs-restarting -r

3. Check every box at once with Ansible

ansible all -m ansible.builtin.setup -a 'filter=ansible_kernel'
ansible all -a 'cat /var/run/reboot-required' --become

The first lists the running kernel on every host. The second errors on hosts that don’t need a reboot, and prints a line on the ones that do.

4. Reboot on purpose

Reboot one box first, confirm it comes back on the new kernel with uname -r, then roll through the rest a few at a time. If you manage your servers with Ansible, put the reboot in a playbook so it happens the same way every time.

God Bless, and Happy hacking!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.