How can I upgrade my standard Amazon Linux 2 kernel version 4.14.x to Amazon Linux Extras kernel versions?

4 minute read
1

I want to upgrade my standard Amazon Linux 2 kernel version 4.14.x to the Amazon Linux Extra version 5.4.x. Or, I want to upgrade my Amazon Linux Extra kernel version 5.4.x to version 5.10.x.

Short description

The default kernel installed on Amazon Linux 2 instances is 4.14.x. You can upgrade the default kernel to an Amazon Linux Extras kernel version 5.4.x. Or, if you have kernel version 5.4.x installed, you can upgrade to version 5.10.x.

Note: You can upgrade directly from Amazon Linux 2 kernel version 4.14.x to 5.10.x without having to upgrade to 5.4.x first.

Resolution

Upgrade the Amazon Linux 2 default kernel from 4.14.x to Amazon Linux Extras kernel 5.4.x

1.    Review the current active kernel version. In the following example, the current kernel version running on the system is 4.14.268-205.500.

[ec2-user@kernel-upgrade ~]$ uname -r
4.14.268-205.500.amzn2.x86_64

2.    Verify what kernel versions are offered by the amazon-linux-extras repository:

[ec2-user@kernel-upgrade ~]$ sudo amazon-linux-extras |grep kernel
35 kernel-ng available [ =stable ]
49 kernel-5.4 available [ =stable ]
55 kernel-5.10 available [ =stable ]

This output lists the three kernel options available from the Amazon Linux Extra repository:

  • kernel-ng
  • kernel-5.4
  • kernel-5.10

3.    Use the amazon-linux-extras tool to install the kernel 5.4:

sudo amazon-linux-extras install kernel-5.4 -y

4.    After the installation completes, verify that the state has changed in amazon-linux-extras:

[ec2-user@kernel-upgrade ~]$ sudo amazon-linux-extras |grep kernel
35 kernel-ng available [ =stable ]
49 kernel-5.4=latest enabled [ =stable ]
_ kernel-5.10 available [ =stable]

Note the line that shows that the state has changed from available to enabled:

49 kernel-5.4=latest enabled [ =stable ]

5.    Verify the installed kernels from the RPM database:

[ec2-user@kernel-upgrade ~]$ rpm -qa |grep kernel
kernel-tools-4.14.268-205.500.amzn2.x86_64
kernel-4.14.268-205.500.amzn2.x86_64
kernel-5.4.181-99.354.amzn2.x86_64

There are now two different kernel versions available: kernel-4.14.268-205.500 and kernel-5.4.181-99.354.

The following example shows that the old kernel is still active:

[ec2-user@kernel-upgrade ~]$ uname -r
4.14.268-205.500.amzn2.x86_64

7.    To activate the latest kernel version, reboot the instance:

[ec2-user@kernel-upgrade ~]$ sudo reboot

8.    Log in to the instance again, and then verify that the new kernel is active:

[ec2-user@kernel-upgrade ~]$ uname -r
5.4.181-99.354.amzn2.x86_64

Upgrade the Amazon Linux 2 (Amazon Linux Extras) kernel from 5.4.x to 5.10.x

1.    Review the kernel active:

[ec2-user@kernel-upgrade ~]$ uname -r
5.4.181-99.354.amzn2.x86_64

2.    Use the amazon-linux-extras tool to verify the available kernel versions:

[ec2-user@kernel-upgrade ~]$ sudo amazon-linux-extras |grep kernel
35 kernel-ng available [ =stable ]
49 kernel-5.4=latest enabled [ =stable ]
_ kernel-5.10 available [ =stable ]

In this example, kernel-5.4 is enabled.

3.    Use the amazon-linux-extras tool to deactivate kernel 5.4:

[ec2-user@kernel-upgrade ~]$ sudo amazon-linux-extras disable kernel-5.4

Note: If you don't deactivate kernel 5.4, then you receive the following error when trying to install kernel 5.10:

"Refusing because kernel-5.10 could cause an invalid combination."

4.    Use the amazon-linux-extras tool to install kernel 5.10:

[ec2-user@kernel-upgrade ~]$ sudo amazon-linux-extras install kernel-5.10 -y

5.    Verify the installed kernels from the RPM database:

[ec2-user@kernel-upgrade ~]$ rpm -qa |grep kernel
kernel-tools-4.14.268-205.500.amzn2.x86_64
kernel-4.14.268-205.500.amzn2.x86_64
kernel-5.4.181-99.354.amzn2.x86_64
kernel-5.10.102-99.473.amzn2.x86_64 <- kernel 5.10.x has been installed

6.    After verifying that the correct kernel is installed, reboot the instance to activate the latest kernel:

[ec2-user@kernel-upgrade ~]$ uname -r
5.4.181-99.354.amzn2.x86_64 

[ec2-user@kernel-upgrade ~]$ sudo reboot

7.    Log in and then confirm that the kernel is activated:

[ec2-user@kernel-upgrade ~]$ uname -r
5.10.102-99.473.amzn2.x86_64

Note: Upgrading the Amazon Linux 2 kernel from 5.10.x to Amazon Linux Extras 5.15.x follows the same steps that are detailed earlier.


AWS OFFICIAL
AWS OFFICIALUpdated a year ago
5 Comments

We followed this guide and trying to upgrade from 5.4 to 5.10, but it is not working. The rpm -qa |grep kernel command does not show 5.10 installed, but udo amazon-linux-extras |grep kernel shows it as enabled. Pls help

replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied a year ago

Hi AWS team can some one respond for the upgrade of the kernel version from 5.10 to 5.15?

replied a year ago

Hi AWS Team! I'm facing the same issue that @rePost-User-5383065 mentioned. Is there any update on this?

profile picture
replied 7 months ago

I was able to migrate the kernel from version 5.4 to 5.10.

TL;DR

Execute the following steps before attempting to install the new kernel version:

$ sudo yum versionlock list # Find if kernel packages are locked there
$ sudo yum versionlock delete <<KERNEL_PACKAGE>>

Long Explanation

yum-versionlock is a Yum plugin that takes a set of name/versions for packages and excludes all other versions of those packages. This allows you to protect packages from being updated by newer versions.

  1. Try to update the kernel using yum and notice that the plugin versionlock is loaded:

$ sudo yum update kernel

  1. Check if there are any packages locked to their installed versions:

$ sudo yum versionlock list

  1. Discard the list of locked packages, and retry the kernel upgrade:

$ sudo yum versionlock delete <<PACKAGE>>

3.1. [OPTIONAL] To clear all the locked packages use the below command:

$ sudo yum versionlock clear

  1. To display and confirm that the kernel is not locked run the below command:

$ sudo yum versionlock list

  1. Continue installing the new kernel.
profile picture
replied 7 months ago