RASPBIANの設定

Linuxはあまりよくわからないけれど、吊るしの状態から少しだけカスタマイズしよう。

sshでログインする

RASPBIANはインストール直後からsshが有効になっています。デフォルトユーザーはpi、パスワードはraspberryです。有線LANでMacとつないでいればすぐにログインできます。

$ ssh -l pi raspberrypi.local
The authenticity of host 'raspberrypi.local (fe80::2caa:f0e6:cf70:3f64%en4)' can't be established.
ECDSA key fingerprint is SHA256:RTopB4E1E8xdYL+NCC3YYpULqWdCjkk+cSZfkyko9i8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'raspberrypi.local,fe80::2caa:f0e6:cf70:3f64%en4' (ECDSA) to the list of known hosts.
pi@raspberrypi.local'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.
pi@raspberrypi:~ $

ログインできました。

ディスク領域を拡大する

ログインできるようになったらディスク領域を拡大しましょう。

RASPBIANのLITE版のディスクイメージファイルは1.2GBなので、当然これを展開したディスク容量も1.2GBです。dfで使用量を確認したらそのうちの74%が使用済みでした。

これからいろいろ作業するには心許ない残量。マイクロSDカードの容量は4GBあるので残りの3GBも利用するようraspi-configでパーティションサイズを拡大します。

pi@raspberrypi:~ $ LANG=C sudo raspi-config

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): Disk /dev/mmcblk0: 3.9 GiB, 4116709376 bytes, 8040448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe6a544c8

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        8192  131071  122880   60M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      131072 2658303 2527232  1.2G 83 Linux

Command (m for help): Partition number (1,2, default 2):
Partition 2 has been deleted.

Command (m for help): Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): Partition number (2-4, default 2): First sector (2048-8040447, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (131072-8040447, default 8040447):
Created a new partition 2 of type 'Linux' and of size 3.8 GiB.

Command (m for help): Disk /dev/mmcblk0: 3.9 GiB, 4116709376 bytes, 8040448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe6a544c8

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        8192  131071  122880   60M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      131072 8040447 7909376  3.8G 83 Linux

Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

設定終了後、sudo rebootで設定反映すると/dev/rootの空き容量が2.8GBに増えました。

pi@raspberrypi:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.7G  816M  2.8G  23% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M  6.2M  457M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1   60M   20M   41M  34% /boot

RASBIANを最新版に更新してカスタマイズ

aptでパッケージの更新後、rpi-updateをインストールしてブートローダの更新をします。

pi@raspberrypi:~ $ sudo apt update
pi@raspberrypi:~ $ sudo apt upgrade
pi@raspberrypi:~ $ sudo apt install rpi-update
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
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Remove old firmware backup
 *** Backing up firmware
 *** Remove old modules backup
 *** Backing up modules 4.1.18-v7+
#############################################################
This update bumps to rpi-4.1.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=113753
##############################################################
 *** 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    129      0 –:–:–  0:00:01 –:–:–   129
100 49.3M  100 49.3M    0     0   169k      0  0:04:57  0:04:57 –:–:–  309k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 4.1.19-v7+
 *** depmod 4.1.19+
 *** 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 2a7eb4fc4cef07906c36e9adcf76f053daabe371
 *** A reboot is needed to activate the new firmware

ここまでの内容をddでバックアップしておきます。

バックアップも一旦diskutil unmountDiskで取り出してから実行しますが、イメージファイルサイズを抑えるためgzipで圧縮しておきましょう。ddはofオプションを指定しなとそのまま標準出力にデータを流すので、これをパイプで受けてgzip圧縮します。

sudo dd bs=1m if=/dev/rdisk3 | gzip -c > raspbian-jessie-lite-backup.img.gz

ここでもデバイスファイルをr付きで扱うと処理が速くなります。

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments