我想升级我的 Amazon Elastic Compute Cloud (Amazon EC2) 实例上的长期支持 (LTS) Ubuntu 版本。
解决方法
您只能将 LTS Ubuntu 版本升级到下一个顺序版本。例如,要从 LTS Ubuntu 版本 18.04 升级到版本 24.04,必须先升级到版本 20.04。然后,升级到 22.04,最后升级到 24.04。
**先决条件:**请查看 Ubuntu 网站上的 Pre-upgrade checklist。此外,请创建数据备份。
更新您的系统
完成以下步骤:
-
要检查您的操作系统 (OS) 版本,请运行 lsb_release 命令:
lsb_release -a
输出示例:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
-
要为现有 LTS Ubuntu 版本安装所有可用更新,请运行以下命令:
sudo apt update
sudo apt upgrade
-
重启服务器。
**注意:**最佳做法是在安装更新后同时重启实例,以验证您运行的是最新的内核。
升级 LTS Ubuntu 版本
完成以下步骤:
-
要升级 Ubuntu 版本,请运行 Ubuntu 命令 do-release-upgrade:
sudo do-release-upgrade
-
查看收到的摘要中的升级,然后按 Y。
升级摘要示例:
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]
-
如果现有版本中存在升级可能会覆盖的自定义配置,则实用程序会提示您确认更改。要安装软件包维护者的版本,请按 Y。要保留现有版本,请按 N。某些场景(例如 /boot/grub/menu.lst)需要您安装软件包维护者的版本。
提示符示例:
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] ?
-
要删除过时的软件包,请在以下提示符中按 Y:
Searching for obsolete softwareReading state information... Done
Remove obsolete packages?
73 packages are going to be removed.
Continue [yN] Details [d]
-
要重启系统,请在以下提示符中按 Y:
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]
**注意:**必须重启实例才能完成升级。
-
要检查您的 Ubuntu 版本,请运行 lsb_release 命令:
lsb_release -a
输出示例:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: focal