LoginSignup
13
14

More than 5 years have passed since last update.

Raspberry Pi 2にUbuntu 14.04を入れてみた

Posted at

Raspberry Pi 2 Modelを入手したのでUbuntu 14.04を入れてみた。
ここではその手順を記録する。

Raspberry Piについて

Amazonでケース付きのを購入してみた。

再起動を繰り返す現象について

途中ログインまでいかずに再起動を繰り返す現象が発生した。

以下のような記事を参照してUSBアダプターを変更すると現象は収まった。
Raspberry Pi 2 Model B をインストールしてSSH接続できるようにしてみる – CLARA ONLINE techblog

最初は、以下の記事にあるのと同じSDカード(Apotop microSDHC 32GB CL10)を使っていたので相性かと思ったが、他のSDカードに変えても現象が発生するため違ったようだった。
Raspberry PiでSDカード相性が原因で起動エラーを繰り返す時の対処法 | 1ft-seabass.jp.MEMO

UbuntuのイメージをSDカードにインストール

ARM/RaspberryPi - Ubuntu Wikiでメージのzipをダウンロードして解凍。

以下の内容に従ってインストールした。
Installing Operating System Images - Raspberry Pi Documentation

OSX環境なので以下のようにした。

# SDカードのデバイス確認(うちの環境では/dev/disk2だった)
$ diskutil list

$ diskutil unmountDisk /dev/disk[確認したデバイスの番号]

$ sudo dd bs=1M if=[ダウンロードして解凍したイメージのimgファイルパス] of=/dev/rdisk[確認したデバイスの番号]

Ubuntuセットアップ

ARM/RaspberryPi - Ubuntu Wikiの手順に従って以下のようにインストールした。
ユーザ/パスワードはubuntu/ubuntuが設定されているのでそれでログイン。

アップデート

$ sudo apt-get update
$ sudo apt-get upgrade

容量確保

初期では利用できる領域がSDカードの容量に関わらず1GBくらいなのでSDカードの容量いっぱいまで使えるようにする。

$ sudo fdisk /dev/mmcblk0
# 削除 (d, 2)
# 再作成 (n, p, 2, enter, enter)
# 終了 (w)

# 一旦再起動
$ sudo reboot

$ sudo resize2fs /dev/mmcblk0p2

スワップ確保

スワップ領域がないので確保しておく(デフォルト2GB)。

$ sudo apt-get install dphys-swapfile

Wifiドングル用設定

Wifiドングル使うなら入れるらしい。
今は使ってないが予定はあるので入れておく。

$ sudo apt-get install linux-firmware

デスクトップ環境設定

デスクトップ環境も欲しいので入れておく。
軽そうなlxdeにしておく。

# ログイン画面がGUIになると起動がやや遅くなるのでstratxで起動できるようにしておく
# (ログイン画面がGUIでいい場合はlubuntu-desktopを入れるだけで良い)
$ sudo apt-get install lxde

$ vi ~/.xinitrc # 以下を記述
exec startlxde

$ sudo apt-get install xinit

ssh設定

$ sudo apt-get install openssh-server

xorg設定

$ sudo apt-get install xserver-xorg-video-fbturbo

$ sudo vi /etc/X11/xorg.conf # 以下を記述
Section "Device"
    Identifier "Raspberry Pi FBDEV"
    Driver "fbturbo"
    Option "fbdev" "/dev/fb0"
    Option "SwapbuffersWait" "true"
EndSection

$ sudo apt-get install libraspberrypi-bin libraspberrypi-dev
$ sudo ln -s /usr /opt/vc
$ sudo apt-get install libraspberrypi-bin-nonfree

libegl1-mesa-devやlibgles2-mesa-devのインストールが失敗する場合

libraspberrypi-devを入れているとlibegl1-mesa-devやlibgles2-mesa-devが入らなかった。
※ ros-indigo-navigationというパッケージがapt-get installで入らなくて依存関係を見ていったらこの2つのパッケージに依存していた。
その場合、Raspberry Pi • View topic - Ubuntu 14.04 (trusty) Raspberry Pi 2 imageを参考にして以下のようにすることで入れられた。

$ sudo apt-get download libegl1-mesa-dev
$ sudo apt-get download libgles2-mesa-dev

$ sudo dpkg -i --force-overwrite libegl1-mesa-dev_*.deb
# => エラーになる
$ sudo dpkg -i --force-overwrite libgles2-mesa-dev_*.deb
# => エラーになる

$ sudo apt-get install -f

シリアルコンソール有効化

利用する予定はないがとりあえず。

$ sudo vi /boot/cmdline.txt # 以下のように設定
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootwait

$ sudo vi /etc/init/ttyAMA0.conf # 以下のように記述
start on stopped rc or RUNLEVEL=[12345]
stop on runlevel [!12345]

respawn
exec /sbin/getty -L 115200 ttyAMA0 vt102

言語設定

$ sudo apt-get install language-pack-ja
$ sudo update-locale LANG=ja_JP.UTF-8

タイムゾーンの設定

$ sudo cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
13
14
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
13
14