我想在我的Amazon Elastic Compute Cloud (Amazon EC2) 執行個體上升級長期支援(LTS)Ubuntu 版本。
解決方法
您只能將 LTS Ubuntu 版本升級到下一個連續版本。例如,要從 LTS Ubuntu 18.04 版升級到版本 24.04,您必須先升級到版本 20.04。然後,升級到 22.04,最後升級到 24.04。
先決條件: 檢閱 Ubuntu 網站上的升級前檢查清單。另外,創建資料的備份。
更新您的系統
請完成下列步驟:
-
若要檢查您的作業系統 (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 版本,請執行 do-release-upgrade Ubuntu 命令:
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