日記とか、工作記録とか

自分に書けることを何でも書いてゆきます。作った物、買ったもの、コンピュータ系の話題が多くなるかもしれません。

Raspberry pi 2 + Rasbian OS 4.4

Raspberry piのファームウェアアップデートで、カーネルがアップデートされていました。これまでのバージョン4.1から、4.4に変わっているそうです。

pi@raspberrypi:~$ sudo rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
#############################################################
WARNING: This update bumps to rpi-4.4.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=144087
##############################################################
Would you like to proceed? (y/N)
pi@raspberrypi:~$ packet_write_wait: Connection to 192.168.10.104: Broken pipe
MacBook-Air:~ WindVoice$

ここで表示されているURLの議論を読んでみたところ、ドライバモジュールがいくつかカーネルの標準としてロードされるようになったため、ifconfigの表示が変わっているとか話題になっているようです。

この議論自体はトラブルというほどではないのですが、こんな時は何かといろいろ起こるものなので、一応バックアップを取ってからアップデートすることにしました。今回はMacを使ってRaspberry piのバックアップイメージを作成しておきます。参考にしたのは別の方が書いているこちらのブログ

まずはRaspberry piの電源を切って、SDカードを抜きます。

pi@raspberrypi:~$ sudo poweroff

Broadcast message from root@raspberrypi (pts/0) (Sun Apr 17 09:59:35 2016):
The system is going down for system halt NOW!
pi@raspberrypi:~$ Connection to pi closed by remote host.
Connection to pi closed.
MacBook-Air:Documents WindVoice$

Macbook AirにカードリーダをつないでSDカードを接続します。

f:id:WindVoice:20160417100248j:plain

dfコマンドで確認すると、接続前後でデバイスが増えた(/dev/disk2s1)ことがわかります。スライス1(s1)がマウントされていますが、イメージを取得するのはdisk2を丸ごととることになります。

MacBook-Air:Documents WindVoice$ df -k
Filesystem    1024-blocks     Used Available Capacity  iused   ifree %iused  Mounted on
/dev/disk1      117286912 84366624  32664288    73% 21155654 8166072   72%   /
devfs                 180      180         0   100%      624       0  100%   /dev
map -hosts              0        0         0   100%        0       0  100%   /net
map auto_home           0        0         0   100%        0       0  100%   /home
MacBook-Air:Documents WindVoice$ df -k
Filesystem    1024-blocks     Used Available Capacity  iused   ifree %iused  Mounted on
/dev/disk1      117286912 84366468  32664444    73% 21155615 8166111   72%   /
devfs                 183      183         0   100%      636       0  100%   /dev
map -hosts              0        0         0   100%        0       0  100%   /net
map auto_home           0        0         0   100%        0       0  100%   /home
/dev/disk2s1        57288    28240     29048    50%      512       0  100%   /Volumes/boot
MacBook-Air:Documents WindVoice$

デバイスがわかったら、ddコマンドを使ってカードのイメージを取得します。

MacBook-Air:Documents WindVoice$ sudo dd if=/dev/disk2 of=/Users/WindVoice/RPI.img
Password:

しばし待ち…… ますが…… お、遅い…… ddコマンドは昔から使われているコマンドなのですが、進捗状態がわからないのが困ったところです。プログレスパーを出したりできないのかな。とりあえず一回止めて様子を見ることにしました。

MacBook-Air:Documents WindVoice$ sudo dd if=/dev/disk2 of=/Users/WindVoice/RPI.img
Password:
^C15615816+0 records in
15615816+0 records out
7995297792 bytes transferred in 1735.946011 secs (4605730 bytes/sec)
MacBook-Air:Documents WindVoice$

4605730bytes/secとありますので、だいたい4.5MB/秒の転送速度です。ddコマンドのbsオプションで速くならないか試してみたのですが、ほぼ変わらず。カードか、またはカードリーダの性能でこのくらいになってしまうようです。16GBのカードを使用しているので約1時間かかります。

MacBook-Air:Documents WindVoice$ sudo dd if=/dev/disk2 of=/Users/WindVoice/RPI.img bs=8192
1901568+0 records in
1901568+0 records out
15577645056 bytes transferred in 3360.981520 secs (4634850 bytes/sec)
MacBook-Air:Documents WindVoice$ diskutil umountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
MacBook-Air:Documents WindVoice$

SDカードのイメージには未使用の領域も含まれているため、圧縮すると大幅にコンパクトにすることができます。gzipで圧縮しておきます。記録されているデータの内容にもよるのですが、今回は半分以下のサイズにすることができました。

MacBook-Air:~ WindVoice$ ls -l RPI.img
-rw-r--r--  1 root  staff  15577645056  4 17 11:41 RPI.img
MacBook-Air:~ WindVoice$

MacBook-Air:~ WindVoice$ ls -l RPI.img.gz
-rw-r--r--  1 root  staff  6337548426  4 17 11:41 RPI.img.gz
MacBook-Air:~ WindVoice$

SDカードを戻して電源を入れて、updateを実行。アップデート前のバージョンは4.1.21です。

MacBook-Air:Documents WindVoice$ ssh pi@pi
pi@pi's password:
Linux raspberrypi 4.1.21-v7+ #872 SMP Wed Apr 6 17:34:14 BST 2016 armv7l

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: Sun Apr 17 00:49:57 2016 from 192.168.10.106
pi@raspberrypi:~$

pi@raspberrypi:~$ sudo rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
#############################################################
WARNING: This update bumps to rpi-4.4.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=144087
##############################################################
Would you like to proceed? (y/N)
 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168    0   168    0     0    213      0 --:--:-- --:--:-- --:--:--   284
100 50.2M  100 50.2M    0     0   547k      0  0:01:33  0:01:33 --:--:--  133k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 4.4.7-v7+
 *** depmod 4.4.7+
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to 1e84c2891c1853a3628aed59c06de0315d13c4f1
 *** A reboot is needed to activate the new firmware
pi@raspberrypi:~$

アップデートが無事終わったので再起動です。

pi@raspberrypi:~$ sudo reboot

Broadcast message from root@raspberrypi (pts/0) (Sun Apr 17 12:00:33 2016):
The system is going down for reboot NOW!
pi@raspberrypi:~$ Connection to pi closed by remote host.
Connection to pi closed.
MacBook-Air:Documents WindVoice$ ssh pi@pi
pi@pi's password:
Linux raspberrypi 4.4.7-v7+ #876 SMP Tue Apr 12 22:28:41 BST 2016 armv7l

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: Sun Apr 17 02:52:43 2016 from 192.168.10.106
pi@raspberrypi:~$

ログイン直後のメッセージから、確かに4.4.7に変更されたのが確認できました。リモートデスクトップ接続など、基本的な機能は特に問題なく動いています。Raspberry piのコミュニティではIPv6が設定していないのに起動しているとか書いてありましたが、私のところではそんな面白い(?)ことは発生していません。残念。何か違いを感じるようなことがあればまた書こうと思います。