1. ゲスト側の kernel 関連のログ出力の抑止
ログ設定を編集します。
vi /home/jail/client01/etc/syslog.conf
# $FreeBSD: releng/11.2/etc/syslog.conf 308721 2016-11-16 07:04:49Z bapt $
#
# Spaces ARE valid field separators in this file. However,
# other *nix-like systems still insist on using tabs as field
# separators. If you are sharing this file between systems, you
# may want to use only tabs as field separators here.
# Consult the syslog.conf(5) manpage.
*.err;kern.warning;auth.notice;mail.crit /dev/console
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
security.* /var/log/security
auth.info;authpriv.info /var/log/auth.log
mail.info /var/log/maillog
lpr.info /var/log/lpd-errs
ftp.info /var/log/xferlog
cron.* /var/log/cron
!-devd
*.=debug /var/log/debug.log
*.emerg *
# uncomment this to log all writes to /dev/console to /var/log/console.log
# touch /var/log/console.log and chmod it to mode 600 before it will work
#console.info /var/log/console.log
# uncomment this to enable logging of all log messages to /var/log/all.log
# touch /var/log/all.log and chmod it to mode 600 before it will work
#*.* /var/log/all.log
# uncomment this to enable logging to a remote loghost named loghost
#*.* @loghost
# uncomment these if you're running inn
# news.crit /var/log/news/news.crit
# news.err /var/log/news/news.err
# news.notice /var/log/news/news.notice
# Uncomment this if you wish to see messages produced by devd
# !devd
# *.>=notice /var/log/devd.log
!ppp
*.* /var/log/ppp.log
!*
include /etc/syslog.d
include /usr/local/etc/syslog.d
8行目をコメントアウトします。
なるほど。
ゲストのカーネルのログがホスト側に出力されるのを避けるわけですな。
ゲストの空間に出力すればいいような気はしますが・・・。
とりあえず、参考サイトの通りにしておきます。
2. ゲスト側の adjkerntz の停止
これもゲスト側から勝手に時刻を変えられないようにするらしい。
「crontab」を編集します。
vi /home/jail/client01/etc/crontab
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD: releng/11.2/etc/crontab 194170 2009-06-14 06:37:19Z brian $
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute hour mday month wday who command
#
*/5 * * * * root /usr/libexec/atrun
#
# Save some entropy so that /dev/random can re-seed on boot.
*/11 * * * * operator /usr/libexec/save-entropy
#
# Rotate log files every hour, if necessary.
0 * * * * root newsyslog
#
# Perform daily/weekly/monthly maintenance.
1 3 * * * root periodic daily
15 4 * * 6 root periodic weekly
30 5 1 * * root periodic monthly
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time. See adjkerntz(8) for details.
1,31 0-5 * * * root adjkerntz -a
25行目(バージョンによって行番号が変わるので注意。「adjkerntz」の行)をコメント化ですな。
3. ゲスト側の hosts を編集
ゲスト側で、自分を名前解決できるように「hosts」を編集して自分の名前を設定するらしいのですが。
「DHCP」の場合、どうなるのだろう?
これは現在、参考にしているサイトではよくわからないので、保留。
4. GID/UID を重複させないための設定
「jail」の場合、ゲストは独立しているのではなく、ファイルシステムもホストと共有しているので、ホストと同じ「GID/UID」を設定しないようにしなければならないらしい。
とりあえず
/home/jail/client01/etc/pw.conf
というファイルを作成して
defaultpasswd no
minuid 10000
maxuid 19999
mingid 10000
maxgid 19999
と記述します。
ゲスト側の「GID/UID」の範囲を「10000~19999」に設定しています。
実際のファイルも変更する必要があるらしいのですが、それはまた後で・・・。
5. devfs をマウント
ゲスト側で、「dev」が使用できるようにマウントを行います。
mount -t devfs devfs /home/jail/client01/dev
6. chroot して細かな設定
これも実際のことはよくわかっていないのですが、参考サイトのままに
ゲスト環境に「chroot」します。
chroot /home/jail/client01
この時点で「chroot」されているので、パスやファイルを確認すると(ここからのプロンプトは実際には #(シャープ)になります)
$ pwd
/
$ ls
.cshrc boot etc media proc sbin usr
.profile COPYRIGHT lib mnt rescue sys var
bin dev libexec net root tmp
てな感じになっています。
で。
touch /etc/wall_cmos_clock
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
passwd root
パスワード入力のプロンプトが表示されますので、仮想環境の「root」ユーザのパスワードを2回入力します。
New Password:
Retype New Password:
「chroot」から抜けます。
exit