DELAEMON BLOG

Live as if you were to die tomorrow. Learn as if you were to live forever.

Snappy Ubuntu Core@Raspberry Pi 2

MacでSnappy Ubuntu を microSDカードに書いてRaspberry Pi 2にインストールした。
snappy コマンドを使ってみた。

用意したもの

  • RaspberryPi2 Model B
  • スマホ用ACアダプタ 5V2A
  • microUSBケーブル
  • SDカード16GB ※8GBあれば十分、速い方がいいかも。ddコマンドですごく時間がかかる
  • MacBook (LANポートあり) ※無くても問題なし
  • MacBook Air ※基本使ってるのはこっち

OSインストール

インストール方法は以下の通り。
Raspberry Pi 2 | Ubuntu developer portal

$ diskutil list
/dev/disk0
# ~ 省略 ~
/dev/disk1
# ~ 省略 ~
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.9 GB    disk2
   1:             Windows_FAT_32 NO NAME                 15.9 GB    disk2s1

ドキュメントだとDOS_FAT_32になってるけどWindows_FAT_32で問題ない。

$ dela diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful

microSDカードに書き込み開始

$ sudo dd if='/Users/dela/Downloads/ubuntu-15.04-snappy-armhf-rpi2.img' of='/dev/rdisk2'
load: 3.26  cmd: dd 1305 uninterruptible 0.18u 5.78s
56808+0 records in
56807+0 records out
29085184 bytes transferred in 161.721234 secs (179848 bytes/sec)

3.9GBあるのでかなり時間がかかる。

誤ってddを途中で止めてしまった場合はそのままddするとエラー

> sudo dd if='/Users/dela/Downloads/ubuntu-15.04-snappy-armhf-rpi2.img' of='/dev/rdisk2'
dd: /dev/rdisk2: Resource busy

もう一度unmountDiskするとやり直せる

$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
$ sudo dd if='/Users/dela/Downloads/ubuntu-15.04-snappy-armhf-rpi2.img' of='/dev/rdisk2'
load: 3.26  cmd: dd 1305 uninterruptible 0.18u 5.78s

進捗の確認は場合、 MacはCtrl + t で見れる

load: 1.45  cmd: dd 1305 uninterruptible 9.68u 313.88s
2763732+0 records in
2763731+0 records out
1415030272 bytes transferred in 37413.624032 secs (37821 bytes/sec)

すごく待ったわりに、しれっと終わる

7617187+0 records in
7617187+0 records out
3899999744 bytes transferred in 55525.879951 secs (70238 bytes/sec)

microSDカードをRaspberryPiに差し込む。
HDMIケーブルでディスプレイに写す。
ACアダプタ差し込んで起動する。
懐かしい嬉しさ。

ssh

自分のCoregaルーターの設定のせいですんなりsshできなかった。
ルーターの管理画面で無線アクセスポイント設定 / アクセス制限で無線端末間通信と無線‐有線間端末通信をどちらも有効にしたらsshできた。
原因の切り分けにLANポートありのMacBookが役立った。
ルーターを介さずに、インターネット共有を有効にして、
共有する接続経路: Wifi, 相手のコンピューターが使用するポート: Ethrnet にすればRaspberryPiにsshできたので、すぐルーターが怪しいと絞り込めた。

そもそも以下で他のマシーン出てこないのがおかしい

$ arp -a

ubuntuユーザーでログインできる。passwordは直感的にubuntuって打ったら入れた。ですよねー

ssh ubuntu@192.168.1.27
ubuntu@192.168.1.27's password:

Welcome to Ubuntu 15.04 (GNU/Linux 4.2.0-1008-raspi2 armv7l)

 * Documentation:  https://help.ubuntu.com/
Welcome to snappy Ubuntu Core, a transactionally updated Ubuntu.

 * See https://ubuntu.com/snappy

It's a brave new world here in snappy Ubuntu Core! This machine
does not use apt-get or deb packages. Please see 'snappy --help'
for app installation and transactional updates.

Last login: Sun Nov  8 13:21:12 2015 from 192.168.2.1

snappy コマンド

snappy --helpで何ができるか把握

OS情報の確認

(RaspberryPi2)ubuntu@localhost:~$ snappy info
release: ubuntu-core/15.04/stable
architecture: armhf
frameworks: webdm
apps: hello-world.canonical

間違えても教えてくれる。普通ですね、はい

(RaspberryPi2)ubuntu@localhost:~$ snappy version
Unknown command `version', did you mean `versions'?

snappy versionsはそのうち使わなくなるみたい

(RaspberryPi2)ubuntu@localhost:~$ snappy versions
The "versions" command is no longer available.
Please use the "list" command instead to see what is installed.
The "list -u" (or "list --updates") will show you the available updates
and "list -v" (or "list --verbose") will show all installed versions.

インストールされてパッケージの確認

(RaspberryPi2)ubuntu@localhost:~$ snappy list
Name        Date       Version Developer
ubuntu-core 2015-09-25 2       ubuntu
webdm       2015-11-08 0.9.4   sideload
pi2         2015-09-25 0.16    canonical

パッケージ検索

(RaspberryPi2)ubuntu@localhost:~$ snappy search hello-world
Name              Version Summary
glowapi.vtuson    0.1.2   PiGlow RestAPi
hello-dbus-fwk    1.0.2   hello-dbus-fwk
hello-world       1.0.18  hello-world (forks not shown: 2)
spi-test.pedronis 0.3     spi-test
saythis           1.3     saythis
say               1.4     say
Use --show-all to see all available forks.

パッケージインストール

(RaspberryPi2)ubuntu@localhost:~$ sudo snappy install hello-world
Installing hello-world
Starting download of hello-world
21.60 KB / 21.60 KB [====================================================================================>_] 100.00 % 82.01 KB/s
Done
Starting download of icon for package
33.77 KB / 33.77 KB [======================================================================================] 100.00 % 68.73 KB/s
Done
Name        Date       Version Developer
ubuntu-core 2015-09-25 2       ubuntu
hello-world 2015-11-08 1.0.18  canonical
webdm       2015-11-08 0.9.4   sideload
pi2         2015-09-25 0.16    canonical

パッケージが増えたのを確認するのは以下

(RaspberryPi2)ubuntu@localhost:~$ snappy list
Name        Date       Version Developer
ubuntu-core 2015-09-25 2       ubuntu
hello-world 2015-11-08 1.0.18  canonical
webdm       2015-11-08 0.9.4   sideload
pi2         2015-09-25 0.16    canonical

お試し実行。もちろんevilでしょう

(RaspberryPi2)ubuntu@localhost:~$ hello-world.#tabキー
hello-world.echo     hello-world.env      hello-world.evil     hello-world.sh       hello-world.showdev  hello-world.usehw
(RaspberryPi2)ubuntu@localhost:~$ hello-world.evil
Hello Evil World!

そして週末が終わってた。