【WSL2】 Ubuntu 20.04.5 LTS を 22.04 LTS へアップグレード

 WSL2のUbuntuのアップグレードをサボってたのですが、サポート期限が2025年4月までと教えてもらって重い腰を上げました。サボってたというより、特に気にしてなかったというのが正解ですが・・・

 アップグレードには数時間かかることもあるみたいなので、アップグレード予定の人は時間に余裕があるときに実施してください。

アップグレード前のバージョン

$ lsb_release -d
Description:    Ubuntu 20.04.6 LTS

パッケージの更新

$ sudo apt update && sudo apt upgrade && sudo apt autoremove

 まず、パッケージを最新の状態にしておきます。これをしないとアップグレードのときに怒られます。

アップデートマネージャーのインストール

$ sudo apt dist-upgrade && sudo apt install update-manager-core
$ sudo vi /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=lts

 /etc/update-manager/release-upgradesPrompt=lts であることを確認します。今のバージョンがLTSであれば問題ないはずですが、もし Prompt=normal などになってる場合は lts に修正します。

アップグレードの実行

$ sudo do-release-upgrade -d
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS development release
set Prompt=normal in /etc/update-manager/release-upgrades.

 他の参考サイト通り -d オプションを付けてアップグレードを実行したところ、失敗しました。どうやら -d オプションはdevelopmentリリースのインストールを指定するみたいで、もうすでに新バージョンのリリースから十分に時間が経っている場合は -d オプションはいらないみたいです。というわけで -d オプションを外して再実行します。

$ sudo do-release-upgrade

Installing the upgrade can take several hours. Once the download has
finished, the process cannot be canceled.

 Continue [yN]  Details [d]

 今度は成功しました。アップグレードに数時間かかることがありますと警告されますが、構わず y で回答します。

 ここでパッケージの設定をいじっている人は色々聞かれるみたいです。私の場合はmosquittoのバージョンアップについて効かれましたが、大したことはしてなかったので y でアップグレードを続行しました。

 System upgrade is complete.

Action required

Exit all other instances of Ubuntu WSL before continuing.

Unsaved progress may otherwise be lost.

To continue please press [ENTER]

 ここまでくれば完了です。 Enter を押しても特に再起動してくれるわけでもないので自分で再起動します。

 バージョンを確認すると下記のとおりです。

$ lsb_release -d
Description:    Ubuntu 22.04.5 LTS

 ちなみに私は全工程が30分ほどで完了しました。数時間かかるとは何だったのか・・・

コメント

タイトルとURLをコピーしました