インストール時設定
容量節約のためにgame, srcはインストールしない。
rootのパスワードはvagrantに。
ユーザvagrantを追加、パスワードもvagrantに。
sshdは有効に、dumpdevは無効に。
/etc/rc.confの中身
1 2 3 4 5 6 |
hostname="freebsd10" keymap="jp.106.kbd" ifconfig_em0="DHCP" sshd_enable="YES" # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable dumpdev="NO" |
インストール後設定
まずはOSの更新。
1 2 3 4 5 |
# freebsd-update fetch install src component not installed, skipped Looking up update.FreeBSD.org mirrors... none found. Fetching public key from update.FreeBSD.org... done. (略) |
pkgのインストール
pkgをインストールするには、pkg listでもなんでも叩けばインストールしてくれる。
1 2 3 4 |
# pkg list The package management tool is not yet installed on your system. Do you want to fetch install it now? [y/N]: y (略) |
sudoのインストール
vagrant用に。
1 |
# pkg install sudo |
ユーザvagrantにパスワードなしのsudo権限を与える。
requirettyがあればコメントアウト。
1 2 3 |
# visudo vagrant ALL=(ALL) NOPASSWD: ALL |
ユーザvagrantのssh key設定
定番のキーをauthorized_keysとしてダウンロードし、パーミッションを設定する。
1 2 3 4 5 6 7 8 9 |
# mkdir -p /home/vagrant/.ssh # cd /home/vagrant/.ssh # fetch --no-verify-peer -o authorized_keys https://github.com/mitchellh/vagrant/blob/master/keys/vagrant.pub fetch: https://github.com/mitchellh/vagrant/blob/master/keys/vagrant.pub: size of remote file is not known authorized_keys 80 kB 225 kBps 00m00s # # chmod 700 ~vagrant/.ssh # chmod 600 ~vagrant/.ssh/authorized_keys # chown -R vagrant:vagrant ~vagrant |
sshd設定の変更
/etc/ssh/sshd_configに以下を追加。
1 2 3 4 5 |
Port 22 PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 PermitEmptyPasswords no UseDNS no |
空行、コメント行を除くとこんな感じ。
1 2 3 4 5 6 7 |
# egrep -v '^ *#|^ *$' ./sshd_config Port 22 PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 PermitEmptyPasswords no UseDNS no Subsystem sftp /usr/libexec/sftp-server |
sshdを再起動
1 2 3 4 5 |
# service sshd restart Performing sanity check on sshd configuration. Stopping sshd. Performing sanity check on sshd configuration. Starting sshd. |
VirtualBox Guest Additonsは必要か。
FreeBSDのGuest Additionsで以下が可能になる。
https://wiki.freebsd.org/VirtualBox
1 2 3 4 5 |
Clipboard sharing Mouse pointer integration Host Time synchronization Window scaling Seamless mode |
逆に言うと、以上が必要なければわざわざ入れることもない。
もしXを入れないのであれば、インストールしないほうがよい。
pkgのGuest AdditionsはX11のサポートがOnになっており、そのままインストールすると山ほどpackageを追加されるから。
ではportsからコンパイルする?
まずportsディレクトリが必要。
さらに、実はGuest AdditionsのコンパイルにはKernelソースが必要なので、/usr/srcも必要。
しかもportsからのコンパイルするとperlやらgmakeやら、いろんなもののコンパイルが発生する。
本当におすすめしない。
Guest Additionsのインストール
インストールする場合には、pkgからvirtualbo-ose-additonsを。
search -fすると分かるが、X11がOnになっている。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ pkg search -f virtualbox-ose-additions virtualbox-ose-additions-4.3.30 Name : virtualbox-ose-additions Comment : VirtualBox additions for FreeBSD guests Description : These additions are for installation inside a FreeBSD guest. Options : DEBUG : off OPENGL : off X11 : on $ pkg install virtualbox-ose-additions<\pre> /etc/rc.confの変更 |
1 2 3 4 |
$ sudo sysrc vboxguest_enbale=YES vboxguest_enbale: -> YES $ sudo sysrc vboxservice_enable=YES vboxservice_enable: -> YES |
念のため確認
1 2 3 4 |
$ sudo sysrc vboxservice_enable vboxservice_enable: YES $ sudo sysrc vboxguest_enbale vboxguest_enbale: YES |
仮想マシンをパッケージする
シャットダウンしたのち、ホストマシンで梱包
–boxに続けてVirtualBox上の名前を入れる。
1 |
vagrant package --box FreeBSD10 |
できたpackage.boxは約1Gバイト。うーん。ちょっとでかいなあ。