Amazon Linux 2023 をアップデートする
Amazon Linux 2023 へ SSH したところ、ログイン時に下記のメッセージが表示されました。
A newer release of "Amazon Linux" is available.
Version 2023.3.20240108:
Version 2023.3.20240117:
Run "/usr/bin/dnf check-release-update" for full release and version update info
, #_
~\_ ####_ Amazon Linux 2023
~~ \_#####\
~~ \###|
~~ \#/ ___ https://aws.amazon.com/linux/amazon-linux-2023
~~ V~' '->
~~~ /
~~._. _/
_/ _/
_/m/'
Last login: Tue Jan 23 08:09:14 2024 from 217.178.130.27
Amazon Linux 2023 – 長期サポート付きのクラウド最適化 Linux ディストリビューション には下記の記載があり、「dnf update コマンドはインストール済みのパッケージを更新しません」と明記されています。
最後に、Amazon Linux は、柔軟で一貫性のある更新メカニズムである、バージョニングされたリポジトリを通じた決定論的更新を提供します。これは、断然私のお気に入りのポリシーです。ディストリビューションは Amazon Linux パッケージリポジトリの特定のバージョンにロックされるため、更新を適用する方法とタイミングを制御できます。デフォルトでは、Amazon Linux 2 とは異なり、dnf update コマンドはインストール済みのパッケージを更新しません (dnf は yum の後継です)。これは、フリート全体で同じパッケージバージョンが使用されるようにするのに役立ちます。
今回は Amazon Linux 2023 でのシステムアップデート方法をメモしておきます。
検証環境¶
以下の環境で検証しました。
| 対象 | バージョン |
|---|---|
| Amazon Linux | 2023 |
dnf check-update¶
dnf check-update を実行すると以下のように表示されました。
# dnf check-update
Last metadata expiration check: 21:49:14 ago on Mon Jan 22 12:41:32 2024.
=============================================================================================================
WARNING:
A newer release of "Amazon Linux" is available.
Available Versions:
Version 2023.3.20240108:
Run the following command to upgrade to 2023.3.20240108:
dnf upgrade --releasever=2023.3.20240108
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.3.20240108.html
Version 2023.3.20240117:
Run the following command to upgrade to 2023.3.20240117:
dnf upgrade --releasever=2023.3.20240117
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.3.20240117.html
Version 2023.3.20240122:
Run the following command to upgrade to 2023.3.20240122:
dnf upgrade --releasever=2023.3.20240122
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.3.20240122.html
=============================================================================================================
dnf check-release-update¶
dnf check-release-update も dnf update 同様のメッセージが表示されました。
# dnf check-release-update
WARNING:
A newer release of "Amazon Linux" is available.
Available Versions:
Version 2023.3.20240108:
Run the following command to upgrade to 2023.3.20240108:
dnf upgrade --releasever=2023.3.20240108
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.3.20240108.html
Version 2023.3.20240117:
Run the following command to upgrade to 2023.3.20240117:
dnf upgrade --releasever=2023.3.20240117
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.3.20240117.html
Version 2023.3.20240122:
Run the following command to upgrade to 2023.3.20240122:
dnf upgrade --releasever=2023.3.20240122
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.3.20240122.html
dnf upgrade¶
これをアップグレードするには dnf check-release-update の実行結果からアップグレード先バージョンを探し、dnf upgrade --releasever=2023.3.20240122 のように実行します。
もしくは「アップグレード先はその時点の最新で良い」場合、Deterministic upgrades through versioned repositories usage に記載されている通り、バージョン情報の代わりに latest というキーワードを指定することも出来ます。
バージョン/ビルド番号の確認¶
Amazon Linux 自身のバージョン/ビルド番号を確認するには rpm -q system-release を実行します。