WSL2でUbuntu22.04からUbuntu24.04にアップグレードする

はじめに

Ubuntu24.04 LTSがリリースされているので、WSL2で使用しているUbuntu22.04Ubuntu24.04にアップグレードする。

環境

Windows 11 Professional
Ubuntu 22.04

インストール準備

現行バージョンを確認

cat /etc/os-release

PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

最新のパッケージをインストール

sudo apt update && sudo apt upgrade

ディストリビューションアップデート

sudo apt dist-upgrade && sudo apt install update-manager-core
ログ
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
  libheif1 imagemagick node-ip libopenexr25 libmagickcore-6.q16-6-extra
  libmagickwand-6.q16-6 imagemagick-6.q16 libmagickcore-6.q16-6
  imagemagick-6-common libde265-0
Learn more about Ubuntu Pro at https://ubuntu.com/pro
The following packages have been kept back:
  mysql-client python3-update-manager update-manager-core
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  python3-update-manager
The following packages will be upgraded:
  python3-update-manager update-manager-core
2 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 50.7 kB of archives.
After this operation, 6144 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3-update-manager all 1:22.04.20 [39.1 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 update-manager-core all 1:22.04.20 [11.5 kB]
Fetched 50.7 kB in 1s (44.8 kB/s)
(Reading database ... 99073 files and directories currently installed.)
Preparing to unpack .../python3-update-manager_1%3a22.04.20_all.deb ...
Unpacking python3-update-manager (1:22.04.20) over (1:22.04.10) ...
Preparing to unpack .../update-manager-core_1%3a22.04.20_all.deb ...
Unpacking update-manager-core (1:22.04.20) over (1:22.04.10) ...
Setting up python3-update-manager (1:22.04.20) ...
Setting up update-manager-core (1:22.04.20) ...

relese-upgradeの設定

sudo vim /etc/update-manager/release-upgrades
# Default behavior for the release upgrader.

[DEFAULT]
# Default prompting and upgrade behavior, valid options:
#
#  never  - Never check for, or allow upgrading to, a new release.
#  normal - Check to see if a new release is available.  If more than one new
#           release is found, the release upgrader will attempt to upgrade to
#           the supported release that immediately succeeds the
#           currently-running release.
#  lts    - Check to see if a new LTS release is available.  The upgrader
#           will attempt to upgrade to the first LTS release available after
#           the currently-running one.  Note that if this option is used and
#           the currently-running release is not itself an LTS release the
#           upgrader will assume prompt was meant to be normal.
-Prompt=never
+Prompt=lts

アップグレード

アップグレードの実行

sudo do-release-upgrade -d

トラブル

下記がでてきたので、再度 aptで管理しているパッケージを最新化してみる。

Checking for a new Ubuntu release
Please install all available updates for your release before upgrading.
sudo apt update

最下部に下記のエラーが出ている。

1 package can be upgraded. Run 'apt list --upgradable' to see it.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mysql.com/apt/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B7B3B788A8D3785C
W: Failed to fetch http://repo.mysql.com/apt/ubuntu/dists/jammy/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B7B3B788A8D3785C
W: Some index files failed to download. They have been ignored, or old ones used instead.

mysqlのパッケージについての署名鍵の更新が必要らしい。 色々やったが上手く解決できなかったので、mysqlに関連するパッケージを再インストールしてみたら上手く行った。

再度実行

sudo do-release-upgrade -d
[yN] y

Do you want to start the upgrade?
67 packages are going to be removed. 399 new packages are going to be
installed. 862 packages are going to be upgraded.

You have to download a total of 579 M. This download will take about
2 minutes 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

configuring-libc6-01

yes を選択

Remove obsolete packages?


105 packages are going to be removed.

Removing the packages can take several hours.

 Continue [yN]  Details [d]y

Exit all other instances of Ubuntu WSL before continuing.

Unsaved progress may otherwise be lost.

To continue please press [ENTER]

WSL restart required

Exit this instance of Ubuntu WSL.

The upgrade will then be complete.

To continue please press [ENTER]


To sign up for future Ubuntu announcements, please subscribe to Ubuntu's
very low volume announcement list at:

  http://lists.ubuntu.com/mailman/listinfo/ubuntu-announce


Continue [yN] y
Get:1 Upgrade tool signature [833 B]
Get:2 Upgrade tool [1278 kB]
Fetched 1279 kB in 0s (0 B/s)
authenticate 'noble.tar.gz' against 'noble.tar.gz.gpg'
extracting 'noble.tar.gz'
[screen is terminating]

完了したみたい。

確認

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

今後の課題

  • Windows側で登録されているディストリビューション名を変えたい

現時点では下記になっている。 (Ubuntu-22.04という名前)

>wsl --list

Linux 用 Windows サブシステム ディストリビューション:
Ubuntu-22.04 (既定)
docker-desktop-data
docker-desktop

参考

おわりに

Ubuntu22.04からUbuntu24.04への移行を実施した。
Windows側から見える名前を変えたいのだが調べてみるとレジストリをいじる必要がありそうなの保留にしてる・・・

Hugo で構築されています。
テーマ StackJimmy によって設計されています。