Amazon Elastic Compute Cloud (Amazon EC2) インスタンスの長期サポート (LTS) Ubuntu バージョンをアップグレードしたいです。
解決策
LTS Ubuntu バージョンは、順番が次のバージョンにのみアップグレードできます。たとえば、LTS Ubuntu バージョン 18.04 から 24.04 にアップグレードするには、まずバージョン 20.04 にアップグレードしてから、22.04 にアップグレードし、最後に 24.04 にアップグレードする必要があります。
前提条件 Ubuntu のウェブサイトでアップグレード前のチェックリストを確認します。データのバックアップを作成します。
システムを更新する
次の手順を実行します。
-
lsb\ _release コマンドを実行し、オペレーティングシステム (OS) のバージョンを確認します。
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