LoginSignup
1
3

More than 5 years have passed since last update.

Raspberry Pi 2にRaspbian Jessieをセットアップし、自分のユーザーにログイン

Last updated at Posted at 2015-12-30

Raspberry Pi 2を買いました!

raspi2.jpg

ついでにケースも買いました!

case.jpg
case2.jpg

ということで、Raspbian Jessieを入れて自分のユーザーでログインするところまでの流れをメモとして残しておきたいと思います
また、USBマウスやディスプレイは手元に無いので、ssh接続でのみのセットアップ方法になります

前提

項目 内容
本体 Raspberry Pi 2 Model B
Raspbian OS Raspbian Jessie
スクリーンショット 0027-12-31 0.30.48.png
PC Macbook Pro Yosemite 10.10.5
環境 おうち(ルーターへの接続数が少ない)

Raspbian Jessieをダウンロード

https://www.raspberrypi.org/downloads/raspbian/ からRASPBIAN JESSIEをDownload
容量がでかいのでゆっくり待ちます

SDカードへの起動イメージ焼きこみ

SDカードの特定

terminal
$  df -h
Filesystem      Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
/dev/disk1     233Gi  108Gi  125Gi    47% 28319269 32661977   46%   /
devfs          184Ki  184Ki    0Bi   100%      639        0  100%   /dev
map -hosts       0Bi    0Bi    0Bi   100%        0        0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%        0        0  100%   /home
map -fstab       0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers

差分を見るためここでPCにmicroSDカードを挿入

terminal
$  df -h
Filesystem      Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
/dev/disk1     233Gi  108Gi  125Gi    47% 28319269 32661977   46%   /
devfs          184Ki  184Ki    0Bi   100%      639        0  100%   /dev
map -hosts       0Bi    0Bi    0Bi   100%        0        0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%        0        0  100%   /home
map -fstab       0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers
/dev/disk2s1    30Gi  2.4Mi   30Gi     1%        0        0  100%   /Volumes/NO NAME

増えたやつ(今回は最終行)が挿入したmicroSDカード

アンマウント

terminal
$ sudo diskutil unmount /dev/disk2s1 
Password:
Volume NO NAME on disk2s1 unmounted

imgファイルのコピー

disk2s1なら、頭にrを付けてs1を削ったrdisk2とする
数分かかります

terminal
$ sudo dd if=[imgファイルのパス] of=/dev/rdisk2 bs=1m
3752+0 records in
3752+0 records out
3934257152 bytes transferred in 182.878920 secs (21512907 bytes/sec)

最後にアンマウント

terminal
$ sudo diskutil unmount /dev/disk2s1
Password:
Volume boot on disk2s1 unmounted

Raspberry Piの初期設定

Raspberry Piを家のネットワークに接続し、IP割り出し

1. Raspberry PiにmicroSDをカチッと鳴るまで押し込んで挿入

sdcard.jpg

2. microUSBを奥まで挿して電源on(挿れてる途中からPWRランプが光るが、最後まで挿しこむ)

usb.jpg

3. LANケーブルでRaspberry Pi本体とWi-Fiルータを接続

家のネットワーク経由で接続できるようにしておきます

4. iOSアプリのFingを使ってRaspberry PiのIPを割り出す

terminalから頑張って探す方法もあるんですが、結構面倒なので僕はこのアプリを使ってます

Fing.png

sshで接続

PC --> 家のネットワーク --> Raspberry Pi

id password
pi raspberry
terminal
$ ssh pi@192.168.0.13
The authenticity of host '192.168.0.13 (192.168.0.13)' can't be established.
RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.13' (RSA) to the list of known hosts.
pi@192.168.0.13's password: 

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: Sat Nov 21 21:35:31 2015

初期設定

pi@raspberrypi
$ sudo raspi-config 

GUIの設定画面が開く

sudo raspi-config.png

日本語へ表示を変更

5 Internationalisation Options
↓
11 Change Locale
↓
[*] ja_JP.EUC-JP EUC-JP
[*] ja_JP.UTF-8 UTF-8 
↓
Default Locale は ja_JP.UTF-8 を選択
Internationalisation Options Change Locale Locale選択 Default Local
スクリーンショット 0027-12-30 22.26.08.png スクリーンショット 0027-12-30 22.26.18.png スクリーンショット 0027-12-30 22.27.04.png スクリーンショット 0027-12-30 22.28.06.png
pi@raspberrypi
Generating locales (this might take a while)...
  en_GB.UTF-8... done
  ja_JP.EUC-JP... done
  ja_JP.UTF-8... done
Generation complete.

タイムゾーン変更

5 Internationalisation Options 
↓
12 Change Timezone
↓
Asia
↓
Tokyo
Change Timezone Geographic area選択 Time zone選択
スクリーンショット 0027-12-30 22.35.03.png スクリーンショット 0027-12-30 23.10.18.png スクリーンショット 0027-12-30 23.10.25.png
pi@raspberrypi
Current default time zone: 'Asia/Tokyo'
Local time is now:      Wed Dec 30 22:36:40 JST 2015.
Universal Time is now:  Wed Dec 30 13:36:40 UTC 2015.

ユーザー追加

自分用のuserを追加

pi@raspberrypi
$ sudo adduser naoto0n2
Adding user `naoto0n2' ...
Adding new group `naoto0n2' (1001) ...
Adding new user `naoto0n2' (1001) with group `naoto0n2' ...
Creating home directory `/home/naoto0n2' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for naoto0n2
Enter the new value, or press ENTER for the default
    Full Name []: 
    Room Number []: 
    Work Phone []: 
    Home Phone []: 
    Other []: 
Is the information correct? [Y/n] Y

面倒なので全部そのままENTERでdefault

権限付与

pi@raspberrypi
$ sudo visudo

nanoエディタというエディタが開くので、最後の行に
【user名】 ALL=(ALL) ALL
と追記し、保存して終了 (control+x → y → Enter)

スクリーンショット 0027-12-30 23.25.44.png

追加したユーザーでログイン

一旦ログアウト

pi@raspberrypi
$ logout

設定したuser名でログイン

terminal
$ ssh naoto0n2@192.168.0.13
naoto0n2@192.168.0.13's password: 

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.

初期IDのpiはもう不要になったので、削除

naoto0n2@raspberrypi
$ sudo userdel pi

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for naoto0n2: 
userdel: user pi is currently used by process 466

これで

完了!

1
3
0

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
1
3