====== Raspberry Pi Model BでFreeBSD 11-RELEASEを使う ======
===== 試した環境 =====
* Raspberry Pi 1 Model B
* FreeBSD 11.0-RELEASE
* SDHCカード 16GB
===== 起動用SDカードの作成 =====
2017-05-05現在、Raspberry Pi 2まではFreeBSD Foundationが公式にディスクイメージを配布しているので、有り難く使わせてもらう。
今回は初代ラズパイモデルBにインストールするので、[[ftp://ftp.freebsd.org/pub/FreeBSD/releases/arm/armv6/ISO-IMAGES/11.0/]]から名前に”RPI-B”が入っているファイルをダウンロードする。その後、展開してイメージを書き込む。
$ curl -O ftp://ftp.freebsd.org/pub/FreeBSD/releases/arm/armv6/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-arm-armv6-RPI-B.img.xz
# zcat FreeBSD-11.0-RELEASE-arm-armv6-RPI-B.img.xz | dd of=/dev/disk2 bs=4m
正常に書き込めてれば、MSDOSBOOT(FAT32)とrootfs(UFS)の2パーティションが出来上がる。
===== 起動 =====
===== 設定 =====
デフォルトでDHCPクライアントとsshdが有効になっている。SSHでのrootログインは許可されていないが、通常のFreeBSDと違って一般ユーザーfreebsd(パスワード:freebsd)が追加されているため、そちらでsshして作業することが出来る。素晴らしい!
参考までにデフォルトの/etc/rc.confは下記の通り。
hostname="rpi-b"
ifconfig_DEFAULT="dhcp"
sshd_enable="YES"
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
growfs_enable="YES"
==== ユーザーとパスワード ====
rootのデフォルトパスワードが"root"で危険なので変更する。
# passwd
Changing local password for root
New Password:
Retype New Password:
更に、一般ユーザーfreebsdのパスワードも忘れずに変更すること。今回はユーザー自体を削除した。
# rmuser freebsd
Matching password entry:
freebsd:$6$0EIJxhGS4FuBG20x$X2jIJp6lsqaorxM11zzK.Rdm9nxWf3yJaBRvJQQGcN/jO2ksMec4sx4ZwqeOwlC/YL9EL2/pMkPJjUR233YV71:1001:1001::0:0:FreeBSD User:/home/freebsd:/bin/csh
Is this the entry you wish to remove? y
Remove user's home directory (/home/freebsd)? y
Removing user (freebsd): mailspool home passwd.
で、代わりにオレオレ一般ユーザーを追加する。
# adduser
Username: Decomo
Full name:
Uid (Leave empty for default):
Login group [Decomo]:
Login group is Decomo. Invite Decomo into other groups? []: wheel
Login class [default]:
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/Decomo]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : Decomo
Password : *****
Full Name :
Uid : 1001
Class :
Groups : Decomo wheel
Home : /home/Decomo
Home Mode :
Shell : /bin/sh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (Decomo) to the user database.
Add another user? (yes/no): no
Goodbye!
==== IPアドレス設定 ====
IPアドレスは固定で使いたいので、/etc/rc.confを以下のように変更。言うまでもないが、各IPアドレスとネットマスクは適切に読み替えて下さい。
ifconfig_DEFAULT="dhcp"
↓
ifconfig_ue0="inet 172.16.0.100 netmask 255.255.0.0"
defaultrouter="172.16.0.1"
DHCPが上手く動いてれば/etc/resolv.confは自動生成されるようだ。出来てなければ以下のようにDNSサーバを追加する。
nameserver 172.16.0.1
==== 時刻の設定 ====
標準のRaspberry PiはRTCを持っておらず電源を切ると時刻が狂ってしまうため、NTPはほぼ必須。
/etc/ntp.confに以下のサーバ設定を追加する(追加しなくても問題はないが折角なので国内のサーバを使う)。
server ntp.nict.jp iburst
server ntp.jst.mfeed.ad.jp
/etc/rc.confに以下を追加する。
# ntpdを自動起動
ntpd_enable="YES"
# システム起動時にntpで時刻を同期する
ntpd_sync_on_start="YES"
タイムゾーンを日本にする。
# tzsetup
Select local or UTC (Greenwich Mean Time) clock) → Yes
Time Zone Selector → Asia
Countries in Asia → Japan
Confirmation → Yes
動作確認
root@rpi-b:/etc # date
Tue Oct 4 00:18:59 JST 2016
root@rpi-b:/etc # ntpdate ntp.nict.jp
9 May 03:57:06 ntpdate[13204]: step time server 133.243.238.244 offset 18761824.277360 sec
root@rpi-b:/etc # date
Tue May 9 03:57:11 JST 2017
root@rpi-b:/etc # /etc/rc.d/ntpd start
Starting ntpd.
root@rpi-b:/etc # ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp-b2.nict.go. .NICT. 1 u 1 64 1 4.112 1.084 0.651
+ntp2.jst.mfeed. 133.243.236.17 2 u 3 64 1 3.804 1.592 0.004
jp.dan.me.uk 193.79.237.14 2 u 2 64 1 5.103 1.898 0.157
*sv01.azsx.net 10.84.87.146 2 u 2 64 1 3.223 1.239 1.277
+mmm21.wni.co.jp 172.16.20.210 3 u 2 64 1 5.227 -4.692 2.161
==== pkg ====
pkgを入れる。
# pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:armv6/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
pkg-static: Warning: Major OS version upgrade detected. Running "pkg-static install -f pkg" recommended
Installing pkg-1.10.1...
Extracting pkg-1.10.1: 100%
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c |-r ] [-C ] [-R ] [-o var=value] [-4|-6] []
For more information on available commands and options see 'pkg help'.