モニタ、キーボード、ACアダプタが不要で、wifi設定が必要なく、USBケーブル1本でセットアップする方法です。
Raspberry Pi Zero 2 W でも、有効と思いますが、まだ、入手できていません。
必要なもの
- Rsspberry Pi Zero WH
- microSDカード
- USBケーブル
Raspberry Pi OS Lite (2022年3月26日時点の最新版)
Release date: January 28th 2022
System: 32-bit
Kernel version: 5.10
Debian version: 11 (bullseye)
Size: 482MB
Raspberry Pi公式ダウンロードページから、OSのイメージファイルをダウンロードします。
https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf-lite.zip
イメージファイルの書き込み
Raspberry Pi公式のイメージ書き込みツール(Raspberry Pi Imager)のMac版を使いました。
https://downloads.raspberrypi.org/imager/imager_latest.dmg
Macのターミナル操作
microSDをリーダーに差します。
Macのターミナルを起動します。
ssh接続を有効にして、USB-OTGのネットワーク接続するコマンドを入力します。
※No such file or directoryと表示される場合は、microSDカードが認識していません。
touch /Volumes/boot/ssh
echo "dtoverlay=dwc2" >> /Volumes/boot/config.txt
sed -i -e '1s/rootwait/rootwait modules-load=dwc2,g_ether/' /Volumes/boot/cmdline.txt
FinderからmicroSDカードを取り出します。
Raspberry Pi OSの起動
microSDをRaspberry Pi Zero本体へ差し込みます。
USBケーブルをUSB端子に差し込みます。
※PWR(電源)の接続は不要です。
ssh接続
USBケーブルをMacに差し込みます。
緑のLEDがチカチカするので、しばらく待ちます。
ssh pi@raspberrypi.local
※初期パスワードは raspberry です。
※ログイン後にパスワードを必ず変更してください。
トラブルシューティング
-
イメージファイルを書き換えた場合など、警告表示でssh接続できないことがあります。
その時は、.ssh/known_hosts ファイルの raspberrypi.localが含まれる行を削除します。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for raspberrypi.local has changed,
and the key for the corresponding IP address
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/xxxx/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/xxxx/.ssh/known_hosts:39
ECDSA host key for raspberrypi.local has changed and you have requested strict checking.
Host key verification failed.