I want to upgrade the long term support (LTS) Ubuntu version on my Amazon Elastic Compute Cloud (Amazon EC2) instance.
Short description
You can upgrade the LTS Ubuntu version of your EC2 instance only to the next sequential version. For example, to upgrade from LTS Ubuntu version 18.04 to version 24.04, you must first upgrade to version 20.04. Then, upgrade to 22.04, and finally upgrade to 24.04.
Resolution
Prerequisites:
Update your system
Complete the following steps:
-
To check your operating system (OS) version, run the following command:
lsb_release -a
Example output:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
-
To install all the available updates for your existing LTS Ubuntu version, run the following commands:
sudo apt update
sudo apt upgrade
-
Reboot the server.
Note: It's a best practice to also reboot the instance after you install the updates to verify that you run the latest kernel.
Upgrade your LTS Ubuntu version
Complete the following steps:
-
To upgrade the Ubuntu version, run the following Ubuntu command:
sudo do-release-upgrade
Note: You can upgrade to the next LTS Ubuntu version release only after the first point release of the latest LTS version. For example, to upgrade Ubuntu 18.04 LTS to 20.04 LTS, Ubuntu must release 20.04.1. To test or evaluate an upgrade earlier than the point release, add the -d flag to the preceding command to upgrade to a development release of Ubuntu. Don't use the -d flag for production environments. Development releases aren't fully tested or supported. For a list of releases and support status, see List of releases on the Ubuntu website.
-
Review the upgrades in the summary that you receive, and then press Y.
Example upgrade summary:
Do you want to start the upgrade?
3 packages are going to be removed. 90 new packages are going to be
installed. 567 packages are going to be upgraded.
You have to download a total of 356 M. This download will take about
1 minute with your connection.
Installing the upgrade can take several hours. Once the download has
finished, the process cannot be canceled.
Continue [yN] Details [d]
-
If there are custom configurations in your existing version that the upgrade might overwrite, then the utility prompts you to confirm the changes. It's a best practice to use the default selection. To keep the existing versions, press N. To install the package maintainer's version, press Y. Some scenarios, such as /boot/grub/menu.lst, require you to install the package maintainer's version. To view the differences in the file versions, press D.
Example prompt:
Configuration file '/etc/ssh/ssh_config' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** ssh_config (Y/I/N/O/D/Z) [default=N] ?
-
To remove obsolete packages, press Y for the following prompt:
Searching for obsolete software
Reading state information... Done
Remove obsolete packages?
73 packages are going to be removed.
Continue [yN] Details [d]
-
To reboot the system, press Y for the following prompt:
System upgrade is complete.Restart required
To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.
Continue [yN]
-
Reboot the instance to complete the upgrade.
-
To check your Ubuntu version, rerun the following command:
lsb_release -a
Example output:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: focal