Ubuntu22.04LTS にアップグレードした

Posted on 2022-05-06 in zakki

LTS リリースということで、恒例となりつつある Ubuntu のアップグレードをした。22.04LTSです。過去のアップグレードとそう大差はないですが、手順のメモをしておく。

アップグレード手順

Ubuntu 公式でもアップグレード手順に関する簡単なドキュメントは用意されているので参考に見ておく。

パッケージ更新

$ sudo apt update
$ sudo apt upgrade

aptコマンドでパッケージの更新を行う。以前実施したときはupgradeでエラー応答が帰ってきたようでしたが、今回はそんなこともなく正常終了。幸先がよい。

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
:
:
After this operation, 495 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
:
:
Get:322 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 cloud-init all 22.1-14-g2e17a0d6-0ubuntu1~20.04.3 [483 kB]
Get:323 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 usb-modeswitch-data all 20191128-3 [32.3 kB]
Get:324 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 usb-modeswitch amd64 2.5.2+repack0-2ubuntu3 [53.1 kB]
Fetched 585 MB in 17s (33.7 MB/s)
:
:
Found linux image: /boot/vmlinuz-4.4.0-1052-aws
Found initrd image: /boot/microcode.cpio /boot/initrd.img-4.4.0-1052-aws
done

再起動

do-release-upgrade前に一度再起動をします。さようなら、518 日間の日々。

$ top
top - 07:36:38 up 518 days, 16:45,  1 user,  load average: 0.00, 0.20, 0.29
Tasks: 100 total,   1 running,  99 sleeping,   0 stopped,   0 zombie

再起動後に作業するために再度 ssh で接続するわけですが、なかなか再接続できなくて焦った。10 分強ぐらいだろうか。upgrade後の終了処理か、直後の起動処理に時間がかかっていたように思われる。ちょうどバックアップで取得していたスナップショットから戻すか …?とか考え始めたころに接続できるようになったので、こちらの行動を見られているなと感じた。

アップグレード

do-release-upgradeでアップグレードを行います。

次回のリリースポイント (22.04だと22.04.01のリリース ) を迎えないと、通常はアップグレードはできない。-dをつけることによってアップグレードを強制させることができるのでそうする。ちなみに、22.04.01のリリース予定は2022 年夏頃と思われます。

$ sudo do-release-upgrade -d

Reading cache

Checking package manager

Continue running under SSH?

This session appears to be running under ssh. It is not recommended
to perform a upgrade over ssh currently because in case of failure it
is harder to recover.

If you continue, an additional ssh daemon will be started at port
'1022'.
Do you want to continue?

Continue [yN]y

ssh の予備用ポートとして1022を使用できるよという通知。yで継続。config に存在するいくつかの Deprecated が表示されつつ、1022のアナウンスが表示されました。

/etc/ssh/sshd_config line 16: Deprecated option UsePrivilegeSeparation
/etc/ssh/sshd_config line 19: Deprecated option KeyRegenerationInterval
/etc/ssh/sshd_config line 20: Deprecated option ServerKeyBits
/etc/ssh/sshd_config line 31: Deprecated option RSAAuthentication
/etc/ssh/sshd_config line 38: Deprecated option RhostsRSAAuthentication

Starting additional sshd

To make recovery in case of failure easier, an additional sshd will
be started on port '1022'. If anything goes wrong with the running
ssh you can still connect to the additional one.

アップグレードで削除 / 更新されるパッケージがあるよという旨のアナウンスが表示されました。確認したい場合はdで、続けたい場合はyで進む。

Do you want to start the upgrade?


13 installed packages are no longer supported by Canonical. You can
still get support from the community.

9 packages are going to be removed. 108 new packages are going to be
installed. 771 packages are going to be upgraded.

You have to download a total of 717 M. This download will take about
2 minutes with a 40Mbit connection and about 19 minutes with a 5Mbit
connection.

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

 Continue [yN]  Details [d]

libc6の自動更新に関するアナウンス。影響はなさそう ( 少し調べたけどよく影響有無がわからなかった ) なので、そのまま進める。

Running services and programs that are using NSS need to be restarted, otherwise they might not be able to do lookup or authentication any more (for services such as ssh, this can affect your ability to login).   │
│ Please review the following space-separated list of init.d scripts for services to be restarted now, and correct it if needed.                                                                                       │
│                                                                                                                                                                                                                      │
│ Note: restarting sshd/telnetd should not affect any existing connections.                                                                                                                                            │
│                                                                                                                                                                                                                      │
│ Services to restart for GNU libc library upgrade:                                                                                                                                                                    │
│                                                                                                                                                                                                                      │
│ cron atd____________________________________________________________________________________________________________________________________________________________________________________________________________ │
│                                                                                                                                                                                                                      │
│                                                                                                        <Ok>                                                                                                          │
│                                                                                                                                                                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

journaldの更新アナウンス。こちらは現状維持したかったので、Nを選択して次へ。

Configuration file '/etc/systemd/journald.conf'
 ==> 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.
*** journald.conf (Y/I/N/O/D/Z) [default=N] ?

crontabの更新アナウンス。こちらも現状維持したかったので、Nを選択して次へ。

Configuration file '/etc/crontab'
 ==> 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.
*** crontab (Y/I/N/O/D/Z) [default=N] ?

dockerの再起動選択アナウンス。Yesを選択します。

┌───────────────────────────────────────────────────────────────────────────────────────────────┤ Configuring docker.io ├────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                                                                        │
│ If Docker is upgraded without restarting the Docker daemon, Docker will often have trouble starting new containers, and in some cases even maintaining the containers it is currently running. See                     │
│ https://launchpad.net/bugs/1658691 for an example of this breakage.                                                                                                                                                    │
│                                                                                                                                                                                                                        │
│ Normally, upgrading the package would simply restart the associated daemon(s). In the case of the Docker daemon, that would also imply stopping all running containers (which will only be restarted if they're part   │
│ of a "service", have an appropriate restart policy configured, or have some other means of being restarted such as an external systemd unit).                                                                          │
│                                                                                                                                                                                                                        │
│ Automatically restart Docker daemon?                                                                                                                                                                                   │
│                                                                                                                                                                                                                        │
│                                                                   <Yes>                                                                      <No>                                                                      │
│                                                                                                                                                                                                                        │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

sshの config 更新アナウンス。現状維持したいので、keep the local version currently installedで次へ。

┌────────────────────────────────────────────────────────────────┤ Configuring openssh-server ├────────────────────────────────────────────────────────────────┐
│ A new version (/tmp/tmp.pfJubVJB1T) of configuration file /etc/ssh/sshd_config is available, but the version installed currently has been locally modified.  │
│                                                                                                                                                              │
│ What do you want to do about modified configuration file sshd_config?                                                                                        │
│                                                                                                                                                              │
│                                                     install the package maintainer's version                                                                 │
│                                                     keep the local version currently installed                                                               │
│                                                     show the differences between the versions                                                                │
│                                                     show a side-by-side difference between the versions                                                      │
│                                                     show a 3-way difference between available versions                                                       │
│                                                     do a 3-way merge between available versions                                                              │
│                                                     start a new shell to examine the situation                                                               │
│                                                                                                                                                              │
│                                                                                                                                                              │
│                                                                            <Ok>                                                                              │
│                                                                                                                                                              │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

パッケージの削除アナウンス。dで詳細確認して、yで削除する。

Remove obsolete packages?


97 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]y

アップグレード確認

22.04 LTS になってたのでめでたしめでたし。計 30 分ぐらいか。

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 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

Ubuntu