Amazon Linux 2023 の EC2 インスタンスで distro-sync コマンドを使って指定したバージョンへ変更してみた
はじめに
テクニカルサポートの 片方 です。
Amazon Linux 2023 の EC2 インスタンスで、distro-sync コマンドを利用して指定 Ver に変更可能か確認してみました。
具体的には、releasever=2023.7.20250623 から 2023.7.20250527 へ変更可能であるか確認してみました。
なお、distro-sync コマンドはアップグレードの際でも利用可能です。
やってみた
Amazon Linux 2023 を起動させます。
sh-5.2$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.7.20250527"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2029-06-30"
sh-5.2$
更新可能なリポジトリバージョンを確認して、その後リポジトリバージョンのパッケージに更新します。
sh-5.2$ sudo dnf check-release-update
WARNING:
A newer release of "Amazon Linux" is available.
Available Versions:
Version 2023.7.20250609:
Run the following command to upgrade to 2023.7.20250609:
dnf upgrade --releasever=2023.7.20250609
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.7.20250609.html
Version 2023.7.20250623:
Run the following command to upgrade to 2023.7.20250623:
dnf upgrade --releasever=2023.7.20250623
Release notes:
https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.7.20250623.html
sh-5.2$ sudo dnf upgrade --releasever=2023.7.20250623
Amazon Linux 2023 repository
(略)
Upgraded:
amazon-ec2-net-utils-2.6.0-1.amzn2023.0.1.noarch amazon-linux-repo-s3-2023.7.20250623-0.amzn2023.noarch awscli-2-2.25.0-1.amzn2023.0.1.noarch
curl-minimal-8.11.1-4.amzn2023.0.1.x86_64 dnf-plugin-support-info-1.7-1.amzn2023.noarch glibc-2.34-196.amzn2023.0.1.x86_64
glibc-all-langpacks-2.34-196.amzn2023.0.1.x86_64 glibc-common-2.34-196.amzn2023.0.1.x86_64 glibc-gconv-extra-2.34-196.amzn2023.0.1.x86_64
glibc-locale-source-2.34-196.amzn2023.0.1.x86_64 kernel-libbpf-6.12.31-35.92.amzn2023.x86_64 kernel-livepatch-repo-s3-2023.7.20250623-0.amzn2023.noarch
kernel-tools-6.12.31-35.92.amzn2023.x86_64 libarchive-3.7.4-2.amzn2023.0.3.x86_64 libcurl-minimal-8.11.1-4.amzn2023.0.1.x86_64
libuv-1:1.51.0-1.amzn2023.0.1.x86_64 libxml2-2.10.4-1.amzn2023.0.11.x86_64 openssh-8.7p1-8.amzn2023.0.15.x86_64
openssh-clients-8.7p1-8.amzn2023.0.15.x86_64 openssh-server-8.7p1-8.amzn2023.0.15.x86_64 perl-Class-Struct-0.66-477.amzn2023.0.7.noarch
perl-DynaLoader-1.47-477.amzn2023.0.7.x86_64 perl-Errno-1.30-477.amzn2023.0.7.x86_64 perl-Fcntl-1.13-477.amzn2023.0.7.x86_64
perl-File-Basename-2.85-477.amzn2023.0.7.noarch perl-File-stat-1.09-477.amzn2023.0.7.noarch perl-Getopt-Std-1.12-477.amzn2023.0.7.noarch
perl-IO-1.43-477.amzn2023.0.7.x86_64 perl-IPC-Open3-1.21-477.amzn2023.0.7.noarch perl-POSIX-1.94-477.amzn2023.0.7.x86_64
perl-SelectSaver-1.02-477.amzn2023.0.7.noarch perl-Symbol-1.08-477.amzn2023.0.7.noarch perl-if-0.60.800-477.amzn2023.0.7.noarch
perl-interpreter-4:5.32.1-477.amzn2023.0.7.x86_64 perl-libs-4:5.32.1-477.amzn2023.0.7.x86_64 perl-mro-1.23-477.amzn2023.0.7.x86_64
perl-overload-1.31-477.amzn2023.0.7.noarch perl-overloading-0.02-477.amzn2023.0.7.noarch perl-subs-1.03-477.amzn2023.0.7.noarch
perl-vars-1.05-477.amzn2023.0.7.noarch python3-3.9.23-1.amzn2023.0.1.x86_64 python3-libs-3.9.23-1.amzn2023.0.1.x86_64
python3-setuptools-59.6.0-2.amzn2023.0.6.noarch python3-setuptools-wheel-59.6.0-2.amzn2023.0.6.noarch screen-4.8.0-5.amzn2023.0.4.x86_64
system-release-2023.7.20250623-0.amzn2023.noarch
Installed:
kernel-6.1.141-155.222.amzn2023.x86_64
Complete!
sh-5.2$
再起動させます。
sh-5.2$ sudo shutdown -r now
状態を確認します。
sh-5.2$ sudo needs-restarting -r
No core libraries or services have been updated since boot-up.
Reboot should not be necessary.
sh-5.2$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.7.20250623"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2029-06-30"
sh-5.2$
更新されたので、distro-sync コマンドを利用して指定 Ver (以前の Ver 2023.7.20250527)に変更します。
sh-5.2$ sudo dnf --releasever=2023.7.20250527 distro-sync
Last metadata expiration check: 0:13:33 ago on Sat Jul 5 02:57:52 2025.
Dependencies resolved.
(略)
Downgraded:
amazon-ec2-net-utils-2.5.5-1.amzn2023.0.1.noarch amazon-linux-repo-s3-2023.7.20250527-0.amzn2023.noarch amazon-ssm-agent-3.3.1957.0-1.amzn2023.x86_64
awscli-2-2.23.11-1.amzn2023.0.1.noarch curl-minimal-8.5.0-1.amzn2023.0.5.x86_64 dnf-plugin-support-info-1.6-1.amzn2023.noarch
glibc-2.34-181.amzn2023.0.1.x86_64 glibc-all-langpacks-2.34-181.amzn2023.0.1.x86_64 glibc-common-2.34-181.amzn2023.0.1.x86_64
glibc-gconv-extra-2.34-181.amzn2023.0.1.x86_64 glibc-locale-source-2.34-181.amzn2023.0.1.x86_64 kernel-libbpf-6.12.29-33.102.amzn2023.x86_64
kernel-livepatch-repo-s3-2023.7.20250527-0.amzn2023.noarch kernel-tools-6.12.29-33.102.amzn2023.x86_64 libarchive-3.7.4-2.amzn2023.0.2.x86_64
libcurl-minimal-8.5.0-1.amzn2023.0.5.x86_64 libuv-1:1.47.0-1.amzn2023.0.2.x86_64 libxml2-2.10.4-1.amzn2023.0.10.x86_64
openssh-8.7p1-8.amzn2023.0.14.x86_64 openssh-clients-8.7p1-8.amzn2023.0.14.x86_64 openssh-server-8.7p1-8.amzn2023.0.14.x86_64
perl-Class-Struct-0.66-477.amzn2023.0.6.noarch perl-DynaLoader-1.47-477.amzn2023.0.6.x86_64 perl-Errno-1.30-477.amzn2023.0.6.x86_64
perl-Fcntl-1.13-477.amzn2023.0.6.x86_64 perl-File-Basename-2.85-477.amzn2023.0.6.noarch perl-File-stat-1.09-477.amzn2023.0.6.noarch
perl-Getopt-Std-1.12-477.amzn2023.0.6.noarch perl-IO-1.43-477.amzn2023.0.6.x86_64 perl-IPC-Open3-1.21-477.amzn2023.0.6.noarch
perl-POSIX-1.94-477.amzn2023.0.6.x86_64 perl-SelectSaver-1.02-477.amzn2023.0.6.noarch perl-Symbol-1.08-477.amzn2023.0.6.noarch
perl-if-0.60.800-477.amzn2023.0.6.noarch perl-interpreter-4:5.32.1-477.amzn2023.0.6.x86_64 perl-libs-4:5.32.1-477.amzn2023.0.6.x86_64
perl-mro-1.23-477.amzn2023.0.6.x86_64 perl-overload-1.31-477.amzn2023.0.6.noarch perl-overloading-0.02-477.amzn2023.0.6.noarch
perl-subs-1.03-477.amzn2023.0.6.noarch perl-vars-1.05-477.amzn2023.0.6.noarch python3-3.9.22-1.amzn2023.0.1.x86_64
python3-libs-3.9.22-1.amzn2023.0.1.x86_64 python3-setuptools-59.6.0-2.amzn2023.0.5.noarch python3-setuptools-wheel-59.6.0-2.amzn2023.0.5.noarch
screen-4.8.0-5.amzn2023.0.3.x86_64 system-release-2023.7.20250527-0.amzn2023.noarch
Complete!
sh-5.2$
再度、再起動させて、状況を確認します。
sh-5.2$ sudo needs-restarting -r
No core libraries or services have been updated since boot-up.
Reboot should not be necessary.
sh-5.2$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.7.20250527"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2029-06-30"
sh-5.2$
成功しました!
まとめ
冒頭での記載の通り、本番運用の場合、distro-sync による巻き戻しは十分な検証と AMI といったバックアップ取得したうえで実施することをお勧めします。
本ブログが誰かの参考になれば幸いです。
参考資料
Identify packages that will require a system reboot after an update - Red Hat Customer Portal
アノテーション株式会社について
アノテーション株式会社は、クラスメソッド社のグループ企業として「オペレーション・エクセレンス」を担える企業を目指してチャレンジを続けています。「らしく働く、らしく生きる」のスローガンを掲げ、様々な背景をもつ多様なメンバーが自由度の高い働き方を通してお客様へサービスを提供し続けてきました。現在当社では一緒に会社を盛り上げていただけるメンバーを募集中です。少しでもご興味あれば、アノテーション株式会社WEBサイトをご覧ください。