RaspberryPi 4 のUbuntu 18.04 LTS → 20.04 LTS にアップデートした

はじめに

Ubuntu18.04 から20.04 へのアップデートの記録になります。

作業環境
・HW : Raspberry Pi 4
・OS : Ubuntu 18.04.5 LTS

1. アップグレード前の下調べ

アップデートを実施する前に、下記のリンクからOSの新機能や注意点を確認します。
アップデート作業自体は簡単ですが、
アップデートした後に既存のアプリケーションが想定しない動作になることは多々あるので、慎重に行う必要があります。

2. OSアップデート

下調べが一通り完了したら、いよいよOSアップデートを行っていきます。
アップデート前に既存のバージョンを確認しておきます。
今回は、Ubuntu 18.04.5 LTS からのバージョンアップを行います。

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
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"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

まず、現在のバージョン(18.04)のパッケージを最新にします。
これを実施しないとバージョンアップができません。
全てのパッケージをアップデートし終えたら、OSのアップデートを行います。

$ sudo apt update
$ sudo apt install update-manager
$ sudo apt dist-upgrade
$ sudo do-release-upgrade -d​

アップデートを進めていくと、LXDのバージョン選択になりあます。
今回はレコメンドの"4.0"を選択しました。

Configuring lxd
---------------

The LXD project puts out monthly feature releases which while backward compatible at an API and CLI level, will contain some behavior change and potentially require manual intervention during an
upgrade.

In addition to those, every 2 years a LTS release is made which comes with 5 years of support through frequent bugfix-only releases.

The LXD team recommends you pick "4.0" for production environments and use "latest" if you're interested in getting the latest LXD features.

[More]

 1. latest  2. 3.0  3. 4.0

LXD snap track 3 --> 「3」を入力。


==> Installing the LXD snap from the 4.0 track for ubuntu-20.04
2020-09-20T14:53:52+09:00 INFO Waiting for automatic snapd restart...

次はログローテートです。
特に今のままでいいので、「N」を選択しました。

Configuration file '/etc/logrotate.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.
*** logrotate.conf (Y/I/N/O/D/Z) [default=N] ? N --> 「N」を入力

sysctl.conf に関しても、今のバージョンで一旦は進めていきます。

Configuration file '/etc/sysctl.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.
*** sysctl.conf (Y/I/N/O/D/Z) [default=N] ? N --> 「N」を入力

次に、SSHをです。
SSHの許可ポートを任意設定しているので「2」を選択します。

Configuring openssh-server
--------------------------

A new version (/tmp/fileXE5UBr) of configuration file /etc/ssh/sshd_config is available, but the version installed currently has been locally modified.

 1. install the package maintainer's version    4. show a side-by-side difference between the versions  7. start a new shell to examine the situation
 2. keep the local version currently installed  5. show a 3-way difference between available versions
 3. show the differences between the versions   6. do a 3-way merge between available versions

What do you want to do about modified configuration file sshd_config? 2 --> 「2」 を入力

最後に、アップデートされたかを確認してアップデート作業は完了です。

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
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"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

3. パッケージソースの確認

OSアップデートを実行時に、自身で追加したパッケージリストがコメントアウトされているので、元に戻していきます。

$ cd /etc/apt/sources.list.d/

$ ls -lh 
-rw-r--r-- 1 root root  85 Sep 20 16:24 kubernetes.list
-rw-r--r-- 1 root root  54 Sep 20 14:27 kubernetes.list.distUpgrade

$ cat kubernetes.list
# deb https://apt.kubernetes.io/ kubernetes-xenial main # disabled on upgrade to focal

$ sudo mv kubernetes.list.distUpgrade kubernetes.list

$ cat kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main

最後に、パッケージのアップデートを行い完了です。
場合によっては、apt update コマンドでエラーが発生しますが、
キャッシュクリアを行えば大抵解決します。

$ sudo apt clean
$ sudo apt update
$ sudo apt dist-upgrade
$ sudo apt autoremove

おわりに

OSアップデート自体は簡単に実行することができました。
私の環境では、Kubernetesを動かしており、今回のアップデート実施後に下記のリンクに記載してあるネットワークの設定を追加する必要がありました。


この記事が気に入ったらサポートをしてみませんか?