ITエンジニアbigwoodsのブログ

IT関連や40歳から始めたロードバイクなどについて

Raspberry Piにディスプレイを使わずOS Raspbianをインストール

Raspberry Pi Model B+が発売されたという記事を見て興味が湧く。

家にはディスプレイ、キーボード、マウスがないという環境。

ディスプレイ、キーボード、マウスがない環境でも使えるということなので衝動買い。

まずは、ディスプレイ、キーボード、マウスがない環境でLAN越しにOSのRaspbianをインストールしてみました。

作業用のパソコンは、Macです。

 

用意したもの

1. Raspberry Pi Model B+

Raspberry Pi Model B+ (Plus)

Raspberry Pi Model B+ (Plus)

 


2. microSDカード

【Amazon.co.jp限定】Transcend microSDHCカード 32GB Class10 (無期限保証) TS32GUSDHC10E (FFP)

【Amazon.co.jp限定】Transcend microSDHCカード 32GB Class10 (無期限保証) TS32GUSDHC10E (FFP)

 


3. USB電源アダプタ & microUSBケーブル

 ANKER Astro M3 モバイルバッテリーを購入したときの電源アダプタとmicroUSBケーブルを使用

 

手順

microSDカードへのOSのインストールは下記の公式ページの手順に従っています。

http://www.raspberrypi.org/documentation/installation/installing-images/README.md

http://www.raspberrypi.org/documentation/installation/installing-images/mac.md

 

1. Raspbianのイメージをダウンロード

 公式ページのhttp://www.raspberrypi.org/downloads/からRaspbianのZIPファイルをダウンロードします。

 

2. ZIPファイルを解凍

 拡張子がimgのファイルができます。

 

3. ターミナルを起動

 Macのターミナルを起動します。

 

4. microSDカードのドライブの確認

 microSDカードをMacに挿入する前にターミナルでdiskutil listを実行します。
 私の環境ではこんな ↓ 感じ。

$ diskutil list

/dev/disk0

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *251.0 GB   disk0

   1:                        EFI EFI                     209.7 MB   disk0s1

   2:                  Apple_HFS Macintosh HD            250.1 GB   disk0s2

   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk2

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *984.7 GB   disk2

   1:                        EFI EFI                     209.7 MB   disk2s1

   2:                  Apple_HFS Time Machine バッ...    984.4 GB   disk2s2

 

 microSDカードをMacに挿入してもう一度diskutil listを実行します。

$ diskutil list

/dev/disk0

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *251.0 GB   disk0

   1:                        EFI EFI                     209.7 MB   disk0s1

   2:                  Apple_HFS Macintosh HD            250.1 GB   disk0s2

   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *31.3 GB    disk1

   1:             Windows_FAT_32 NO NAME                 31.3 GB    disk1s1

/dev/disk3

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:      GUID_partition_scheme                        *984.7 GB   disk3

   1:                        EFI EFI                     209.7 MB   disk3s1

   2:                  Apple_HFS Time Machine バッ...    984.4 GB   disk3s2

 

 増えたドライブが挿入したmicroSDカードのドライブです。

 

5. microSDカードのドライブをアンマウント

 ターミナルでdiskutil unmountDisk /dev/<disk# from diskutil>を実行します。

$ diskutil unmountDisk /dev/disk1

Unmount of all volumes on disk1 was successful

 

6. microSDカードへイメージを書き込む

 ターミナルで2でできたイメージファイルのあるフォルダに移動します。
 ターミナルでsudo dd bs=1m if=image.img of=/dev/<disk# from diskutil>を実行します。

 私は30分くらいかかりました。

$ sudo dd bs=1m if=2014-06-20-wheezy-raspbian.img of=/dev/disk1

Password:

2825+0 records in

2825+0 records out

2962227200 bytes transferred in 1855.337977 secs (1596597 bytes/sec)

 

7. microSDカードの取り出し

 ターミナルでdiskutil eject /dev/<disk# from diskutil>を実行します。

$ diskutil eject /dev/disk1

Disk /dev/disk1 ejected

 

 MacからmicroSDカードを抜きます。

 

8. Raspberry PiにmicroSDカードを挿入

 

9. Raspberry Piの電源を入れる

 USB電源アダプタにつないだmicroUSBケーブルをRasberry Piにつなぎます。

 

10. Raspberry PiのIPアドレスを確認

 ルータの設定画面のDHCPサーバの設定を調べ追加されたクライアントのIPアドレスがRaspberry PiのIPアドレスになります。

 私の環境では192.168.1.23でした。

 

11. Rasberry Piにログイン

 初期設定のユーザIDはpiで、パスワードはraspberryです。

 Macのターミナルを起動し、ssh pi@<10のIPアドレス>を実行します。

$ ssh pi@192.168.1.23

The authenticity of host '192.168.1.23 (192.168.1.23)' can't be established.

RSA key fingerprint is 6b:18:ef:1a:a4:bc:f9:1a:d5:1b:85:33:72:a1:6d:95.

Are you sure you want to continue connecting (yes/no)?

 

 yesを入力します。 

 

Warning: Permanently added '192.168.1.23' (RSA) to the list of known hosts.

Connection closed by 192.168.1.23

 

 接続が切れるので、再びターミナルでssh pi@<10のIPアドレス>を実行します。

$ ssh pi@192.168.1.23

pi@192.168.1.23's password:

 

 raspberryを入力します。

$ ssh pi@192.168.1.23

pi@192.168.1.23's password: 

Linux raspberrypi 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 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.

 

NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'

 

12. セットアップ

 11の最後のメッセージの指示通りsudo raspi-configを実行します。

 

 

┌─────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├──────────┐

│ Setup Options                                                                │

│                                                                              │

│    1 Expand Filesystem              Ensures that all of the SD card s        │

│    2 Change User Password           Change password for the default u        │

│    3 Enable Boot to Desktop/Scratch Choose whether to boot into a des        │

│    4 Internationalisation Options   Set up language and regional sett        │

│    5 Enable Camera                  Enable this Pi to work with the R        │

│    6 Add to Rastrack                Add this Pi to the online Raspber        │

│    7 Overclock                      Configure overclocking for your P        │

│    8 Advanced Options               Configure advanced settings              │

│    9 About raspi-config             Information about this configurat        │

│                                                                              │

│                                                                              │

│                     <Select>                     <Finish>                    │

│                                                                              │

└──────────────────────────────────────────────────────────────────────────────┘