Ubuntu troubleshoot
Troubleshooting

Pending Kernel Upgrade Error in Ubuntu Server

Abhishek
Abhishek

Table of Contents

If you run an Ubuntu 22.04 server, you might run into this "Pending kernel upgrade" message.

  ┌────────────────────────┤ Pending kernel upgrade ├────────────────────────┐
  │                                                                          │ 
  │ Newer kernel available                                                   │ 
  │                                                                          │ 
  │ The currently running kernel version is 5.15.0-41-generic which is not   │ 
  │ the expected kernel version 5.15.0-43-generic.                           │ 
  │                                                                          │ 
  │ Restarting the system to load the new kernel will not be handled         │ 
  │ automatically, so you should consider rebooting.                         │ 
  │                                                                          │ 
  │                                  <Ok>                                    │ 
  │                                                                          │ 
  └──────────────────────────────────────────────────────────────────────────┘ 
                                                                               

It says that the currently running kernel version is not the expected kernel version. It further states that restarting the system to load the new kernel will not be handled automatically and suggests rebooting.

No need to panic about it, my fellow Ubuntu user. Let me explain what this message is all about and what you should be doing about it.

Understanding the pending kernel upgrade message

The first thing, this is not an error message. Your system is providing information about the kernel versions on your Ubuntu server. It is expecting kernel version n-1 to be installed as version n is available, but it finds that your system is using version n-2 or older.

Don't get it? Take a look at the message below.

Pending kernel upgrade message in Ubuntu server

When you update your Ubuntu server using apt upgrade command, it also installs any newer available kernel version. But the newer kernel version is only used when you reboot the system.

In the image above, the new kernel version 5.15.0-43 is available to be installed. The system expects one lower version, i.e., 5.15.0-42 to be installed here. However, it notices that an even older kernel 5.15.0-41 is installed.

Why does it happen? Because when kernel version 5.15.0-42 was installed with the system updates previously, I didn't restart my Ubuntu server.

New kernels are only used when the system is restarted. Since that didn't happen, it kept running 5.15.0-41 even though 5.15.0-42 was installed.

Now when kernel version 5.15.0-43 is available, it is expected to see 5.15.0-42 running, which is not the case, and hence it shows this message.

What should you do?

Press the tab key, and it starts highlighting the <OK> key. Press enter to proceed.

You can continue using the same older kernel. In the future, when an even newer kernel version arrives with the system updates, you will see a similar message again.

Will it be an issue if you run the older kernel version? Not necessarily. Unless there is a CVE that is fixed by the new kernel.

Alternatively, you can choose to reboot your system, and it will start using the latest installed kernel version.

Rebooting a live production server results in downtime. You should plan the reboot accordingly. Notify other users on the server (if any) in advance. If the server is running a public-facing web service, try rebooting when the traffic is minimal.

Coding for Kids | Game-Based Programming | CodeMonkey
CodeMonkey is a fun and educational game environment where students learn to code in real programming languages, no previous experience needed.

Which services should be restarted?

When a new kernel version is installed, you'll be prompted about which services should be restarted.

Which services should be restarted in Ubuntu server?

This is expected behavior. There is a needrestart metapackage installed on Ubuntu 22.04 servers. It runs automatically at the end of each apt upgrade command run and lists if any services need to be restarted (because of the recent libraries upgrade).

In the screenshot above, you may choose not to restart some services if you know they might result in disruption. For example, restarting systemd.login will kill active SSH sessions.

To deselect a service, use the arrow key to highlight it and press the delete key. Press the tab key to select the OK button and press enter.

It will show what all services were restarted.

restarting services in ubuntu

I hope you have a better understanding of the topic now. Let me know if you still have any doubts.