Raspberry Pi 4 Model B 8GB を購入しました。
考え得る最小の接続構成、電源ケーブルのみで Ubuntu 20.04 を起動し、Wi-Fi で操作してみます。
よって、準備するものは下記のみです。
- Raspberry Pi 4 Model B 8GB
- microSDカード32GB
- USB Type-C ケーブル
イメージのダウンロード
Install Ubuntu Server on a Raspberry Pi 2, 3 or 4 にアクセスします。
Ubuntu is an open-source operating system for cross-platform…
RECOMMENDED SERVER と記載されている Ubuntu Server 20.04.2 LTS の Download 64-bit をクリックします。イメージ ubuntu-20.04.2-preinstalled-server-arm64+raspi.img.xz がダウンロードされます。サイズは 700MB 程度でした。
イメージの microSD への書き込み
How to install Ubuntu on your Raspberry Pi にアクセスします。基本的には、記載されている通りに進めればインストールは完了します。
Ubuntu is an open source software operating system that runs…
まず、イメージを書き出すための microSD カードをパソコン (Mac, Linux, Windows) に接続しておきます。microSD カードにイメージを書き出すためには Raspberry Pi Imager を使用します。便利なソフトウェアです。
https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#2-prepare-the-sd-card
からダウンロードできます。
まず、Operating System を設定します。CHOOSE OS をクリックします。

Raspberry Pi Imager で Ubuntu のイメージをダウンロードすることもできるようです。

今回は既に Ubuntu のイメージをダウンロードしているため、 Use custom をクリックします。ここで、事前にダウンロードしておいたイメージファイルを選択します。

続いて、CHOOSE SD CARD をクリックし、イメージを書き出すための microSD カードを選択します。

これで、Operating System と SD Card が設定できました。 WRITE ボタンをクリックすると microSD カードへの書き出しが開始されます。
microSD カードへの書き出しは、6 分程度で完了しました。

Wi-Fi の設定を設定を行うために、いったん microSD カードをパソコンから外します。そして、再度 microSD カードをパソコンを接続しま す。microSD カードの再接続、これ重要です。
Wi-Fi, 無線 LAN の設定
イメージを microSD カードに書き出した後、microSD カードをパソコンから外し、再度 microSD カードをパソコンに接続します。Mac の場合、Finder に system-boot が表示されるようになります。その中の network-config を編集します。Visual Studio Code 等で開いて編集するのがよいでしょう。
network-config のデフォルトは下記の通りでした。
# This file contains a netplan-compatible configuration which cloud-init
# will apply on first-boot. Please refer to the cloud-init documentation and
# the netplan reference for full details:
#
# https://cloudinit.readthedocs.io/
# https://netplan.io/reference
#
# Some additional examples are commented out below
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
#wifis:
# wlan0:
# dhcp4: true
# optional: true
# access-points:
# myhomewifi:
# password: "S3kr1t"
# myworkwifi:
# password: "correct battery horse staple"
# workssid:
# auth:
# key-management: eap
# method: peap
# identity: "me@example.com"
# password: "passw0rd"
# ca-certificate: /etc/my_ca.pem
DHCP
Wi-Fi 設定の部分がコメント化されているため、# を削除し、Wi-Fi 設定を有効にします。例えば下記のような感じです。access-points の 1 つ下の階層には自分の Wi-Fi の SSID を記載します。また、password には自分の Wi-Fi のパスワードを記載します。パスワードの文字の間にスペースがある場合は ” で囲みます。例えば、”my wifi password” のような感じです。
# This file contains a netplan-compatible configuration which cloud-init
# will apply on first-boot. Please refer to the cloud-init documentation and
# the netplan reference for full details:
#
# https://cloudinit.readthedocs.io/
# https://netplan.io/reference
#
# Some additional examples are commented out below
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
my-access-point-name:
password: my-password
# myworkwifi:
# password: "correct battery horse staple"
# workssid:
# auth:
# key-management: eap
# method: peap
# identity: "me@example.com"
# password: "passw0rd"
# ca-certificate: /etc/my_ca.pem
固定 IP アドレス
DHCP ではなく固定にしたい場合、addresses, gateway4, namaservers を設定し、その IP アドレスを記述します。addresses には Raspberry Pi の IP アドレスとサブネット、gateway4 にはデフォルトゲートウェイの IP アドレス、nameservers には DNS サーバーの IP アドレスを記述します。
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: false
optional: true
addresses: [192.168.x.y/24]
gateway4: 192.168.x.1
nameservers:
addresses: [192.168.x.1]
access-points:
my-access-point-name:
password: my-password
Ubuntu の起動と SSH での接続
考え得る最小な構成で、Raspberry Pi 4 で Ubuntu を起動して SSH で接続してみます。
他に準備するものは USB Type-C 1 本のみです。
Raspberry Pi 4 に microSD カードを挿入し、USB Type-C ケーブルを接続して給電します。Raspberry Pi 4 の基板上の赤色 LED が光り始めま す。モニタは接続していないですが、Ubuntu が起動し始めているはずです。
3分ほど待った後、いったん USB Type-C ケーブルからの給電を止め、Ubuntu をシャットダウンします。私の環境では、初回の起動では Wi-Fi を認識しませんでした。
その後、再度 USB Type-C ケーブルを接続し直すなどして給電を再開させ、Ubuntu を再起動させます。3分ほど待つと Ubuntu が再起動す るはずです。
しかし、Raspberry Pi 4 にはモニタを接続していないため、DHCP の場合は Ubuntu が起動したとしても、その IP アドレスを知ることができません。そのため、何らかの Wi-Fi 検出アプリで Raspberry Pi 4 の IP アドレスと思われるものを確認するのがよいでしょう。
Raspberry Pi 4 の IP アドレスを確認した後、SSH で接続してみます。デフォルトのユーザー名とパスワードは共に ubuntu です。ログイン後、すぐにパスワードの変更を求められます。パスワードの変更に成功すると、いったん強制的に切断されます。
% ssh ubuntu@192.168.xxx.yyy
The authenticity of host '192.168.xxx.yyy (192.168.xxx.yyy)' can't be established.
ECDSA key fingerprint is SHA256:xxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.xxx.yyy' (ECDSA) to the list of known hosts.
ubuntu@192.168.xxx.yyy's password:
You are required to change your password immediately (administrator enforced)
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1028-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sun May 16 10:32:25 UTC 2021
System load: 1.78
Usage of /: 6.4% of 28.99GB
Memory usage: 4%
Swap usage: 0%
Temperature: 56.0 C
Processes: 141
Users logged in: 0
IPv4 address for wlan0: 192.168.xxx.yyy
IPv6 address for wlan0: 2...
* Pure upstream Kubernetes 1.21, smallest, simplest cluster ops!
https://microk8s.io/
99 updates can be installed immediately.
42 of these updates are security updates.
To see these additional updates run: apt list --upgradable
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for ubuntu.
Current password:
New password:
Retype new password:
passwd: password updated successfully
Connection to 192.168.xxx.yyy closed.
その後、変更したパスワードを使用し、再度 SSH でログインします。
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1028-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sun May 16 10:44:49 UTC 2021
System load: 1.23
Usage of /: 8.8% of 28.99GB
Memory usage: 6%
Swap usage: 0%
Temperature: 60.4 C
Processes: 148
Users logged in: 0
IPv4 address for wlan0: 192.168.xxx.yyy
IPv6 address for wlan0: 2...
* Pure upstream Kubernetes 1.21, smallest, simplest cluster ops!
https://microk8s.io/
70 updates can be installed immediately.
9 of these updates are security updates.
To see these additional updates run: apt list --upgradable
*** System restart required ***
Last login: Sun May 16 10:42:58 2021 from 192.168.xxx.yyy
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@ubuntu:~$
Ubuntu 起動後の情報は下記の通りでした。
$ uname -a
Linux ubuntu 5.4.0-1028-raspi #31-Ubuntu SMP PREEMPT Wed Jan 20 11:30:45 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.8G 0 3.8G 0% /dev
tmpfs 782M 4.0M 778M 1% /run
/dev/mmcblk0p2 29G 2.6G 26G 10% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 49M 49M 0 100% /snap/core18/1949
/dev/loop1 62M 62M 0 100% /snap/lxd/19040
/dev/loop2 27M 27M 0 100% /snap/snapd/10709
/dev/mmcblk0p1 253M 119M 134M 48% /boot/firmware
/dev/loop3 28M 28M 0 100% /snap/snapd/11843
/dev/loop4 49M 49M 0 100% /snap/core18/2002
/dev/loop5 60M 60M 0 100% /snap/lxd/20330
tmpfs 782M 0 782M 0% /run/user/1000
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"