LoginSignup
34
38

More than 5 years have passed since last update.

Raspberry Piにディスプレイとマウスとキーボートを繋がずに自動でRaspbianをインストールする

Last updated at Posted at 2017-02-13

NOOBSインストーラを使う

NOOBSはRaspberry Piの公式サイトからダウンロードして解凍したものをSDカードフォーマッターでフォーマットしたmicroSDにコピーする

NOOBSインストールをsilentinstallにする

コピーしたmicroSDの直下にあるrecovery.cmdlineにsilentinstallオプションを追加する

recovery.cmdline
runinstaller quiet ramdisk_size=32768 root=/dev/ram0 init=/init vt.cur_default=1 elevator=deadline silentinstall

これでRaspberry PiにmicroSDと有線LAN、電源を挿すと勝手にインストールができる

Raspbianのsshサーバを自動起動設定でインストールをする

Raspbianは初期状態でsshサーバが起動しないので、NOOBSインストール中にsshサーバの自動起動設定を行う

コピーしたmicroSDのos\Raspbianにあるpartition_setup.shにsshサーバの自動起動設定を追記する
@mt08 さんから指摘を受けて修正)

partition_setup.sh(18行目)
#mt08:(↓一行追加) bootパーティションに ssh を作成
touch /tmp/1/ssh

if ! grep -q resize /proc/cmdline; then

あとはこのmicroSDカードをRaspberry Piにセットし電源を入れたらひたすらpingを打ってインストールが完了するのを待つだけ
(ルータ側でdhcpの固定配送を設定して置く)

cmd
ping -t 192.168.xxx.xxx

あとで無線LANの設定方法も書こう

(追記)

Raspbianの無線LANを自動起動でインストールをする

最後に無線LANも自動起動でインストールをすれば、Raspberry Piに電源を挿すだけで済む

partition_setup.sh(18行目に更に追記)
# 無線LANの起動設定
sed -ri '/^allow-hotplug wlan0$/i\auto wlan0' /tmp/2/etc/network/interfaces  
echo "network={" >> /tmp/2/etc/wpa_supplicant/wpa_supplicant.conf
echo "        ssid=\"your_ssid\"" >> /tmp/2/etc/wpa_supplicant/wpa_supplicant.conf
echo "        psk=\"your_password\"" >> /tmp/2/etc/wpa_supplicant/wpa_supplicant.conf
echo "}" >> /tmp/2/etc/wpa_supplicant/wpa_supplicant.conf

#mt08:(↓一行追加) bootパーティションに ssh を作成
touch /tmp/1/ssh

無線LANは一般的なWPA/WPA2のTKIP/AESモードが前提。またRaspberry Piは2.4Ghz帯(チャンネル1~13)にしか対応していないらしいので注意。

アクセスポイントがステルスモードの場合は更に1行追加する

partition_setup.sh(22行目に更に追記)
echo "        scan_ssid=1" >> /tmp/2/etc/wpa_supplicant/wpa_supplicant.conf

参考文献

34
38
2

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
34
38