LoginSignup
2
2

More than 1 year has passed since last update.

Raspberry Pi Zero WHをキーボードなしで初期設定してみる

Last updated at Posted at 2020-02-01

思わず買ってしまったRaspberry Pi Zero WHなんですが、microUSBしかないので家にあるキーボードやマウスを繋げようにも変換器が必要だしLANポートもないしってことで、キーボードなしで初期設定を試みます。

環境

  • Rasiberry Pi Zero WH
  • microSD 16GB

OSのインストールに必要なもの

手順は、以前書いたので省略。

設定

Raspbianを書き込んだSDカードをWindowsのカードリーダに挿します。
(今回はたまたまWindowsを使いました。)

SSHを有効にする

bootドライブ直下にsshという拡張子なしのファイルを作成。

WiFi設定

bootドライブの直下にwpa_supplicant.confというファイルを作成。
ファイルの中身は以下のようにする。

wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP

network={
        ssid="ネットワーク名"
        psk="暗号化キー"
}

起動

設定ファイルを書き込んだSDカードをRaspberry Piに挿して、電源を入れると起動します。

使っているWindowsマシンにはBonjourが入っているので、raspberrypi.localでpingやsshが使えました。

C:\>ping raspberrypi.local

raspberrypi.local [2405:6581:1720:b00:c34e:5107:64b5:244d]に ping を送信しています 32 バイトのデータ:
2405:6581:1720:b00:c34e:5107:64b5:244d からの応答: 時間 =5ms
2405:6581:1720:b00:c34e:5107:64b5:244d からの応答: 時間 =9ms
2405:6581:1720:b00:c34e:5107:64b5:244d からの応答: 時間 =7ms
2405:6581:1720:b00:c34e:5107:64b5:244d からの応答: 時間 =7ms

2405:6581:1720:b00:c34e:5107:64b5:244d の ping 統計:
    パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、
ラウンド トリップの概算時間 (ミリ秒):
    最小 = 5ms、最大 = 9ms、平均 = 7ms

C:\>

SSH接続

初期値のユーザ名はpi、パスワードはraspberryです。

C:\>ssh pi@raspberrypi.local
The authenticity of host 'raspberrypi.local (2405:6581:1720:b00:c34e:5107:64b5:244d)' can't be established.
ECDSA key fingerprint is SHA256:BcbDRhn2Qb0ej05i648FSuy0UJTweL875xCKBurSYiU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'raspberrypi.local,2405:6581:1720:b00:c34e:5107:64b5:244d' (ECDSA) to the list of known hosts.
pi@raspberrypi.local's password:
Linux raspberrypi 4.19.75+ #1270 Tue Sep 24 18:38:54 BST 2019 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Sep 26 01:46:52 2019

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $

パッケージのアップデート

『sudo rpi-update』するほどのことはしないので、今回はパッケージのアップデートにしておく。

パッケージリストの更新

sudo apt updateで管理しているパッケージのリストを更新します。

pi@raspberrypi:~ $ sudo apt update
Get:1 http://archive.raspberrypi.org/debian buster InRelease [25.2 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages [13.0 MB]
Get:4 http://archive.raspberrypi.org/debian buster/main armhf Packages [274 kB]
Fetched 13.3 MB in 33s (399 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
228 packages can be upgraded. Run 'apt list --upgradable' to see them.

パッケージの更新

sudo apt dist-upgradeで実際のパッケージの更新をする。
けっこうなパッケージの量があり、時間がかかる。

pi@raspberrypi:~ $ sudo apt dist-upgrade -y
(量が多いので省略)

dist-upgradeとupgradeの違い

|コマンド|説明|
|---|---|---|
|upgrade|インストールされているパッケージの更新のみ
パッチ適用に伴う追加パッケージのインストールや削除をおこなわない|
|dist-upgrade|ディストリビューションのパッケージの更新
パッチ適用に伴う追加パッケージのインストールや削除をおこなう|

後始末

不要なパッケージなどを削除して空き容量を少しで増やしておく。
『sudo apt autoremove -y』コマンドで、更新に伴い必要なくなったパッケージを削除する。

pi@raspberrypi:~ $ sudo apt autoremove -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  alsa-base gstreamer0.10-alsa gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 libllvm8
  libva-wayland2 libxfce4util-bin libxfce4util-common libxfce4util7 libxfconf-0-2 pimixer point-rpi xfconf
0 upgraded, 0 newly installed, 14 to remove and 0 not upgraded.
After this operation, 68.0 MB disk space will be freed.
(Reading database ... 153509 files and directories currently installed.)
Removing alsa-base (1.0.27+1) ...
Removing pimixer (0.20190918~133938) ...
Removing gstreamer0.10-alsa:armhf (0.10.36-2) ...
Removing gstreamer0.10-plugins-base:armhf (0.10.36-2) ...
Removing libgstreamer-plugins-base0.10-0:armhf (0.10.36-2) ...
Removing libgstreamer0.10-0:armhf (0.10.36-1.5) ...
Removing libllvm8:armhf (1:8-3+rpi1) ...
Removing libva-wayland2:armhf (2.4.0-1) ...
Removing libxfce4util-bin (4.12.1-3) ...
Removing libxfconf-0-2 (4.12.1-1) ...
Removing xfconf (4.12.1-1) ...
Removing libxfce4util7:armhf (4.12.1-3) ...
Removing libxfce4util-common (4.12.1-3) ...
Removing point-rpi (0.20160905) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for gnome-menus (3.31.4-3) ...
Processing triggers for libc-bin (2.28-10+rpi1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for desktop-file-utils (0.23-4) ...
pi@raspberrypi:~ $

『sudo apt autoclean』を実行して、キャッシュされているが、インストールはされていないdebファイルを削除する。

pi@raspberrypi:~ $ sudo apt autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
pi@raspberrypi:~ $
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2