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.