Differences between revisions 2 and 5 (spanning 3 versions)
Revision 2 as of 2004-08-08 18:13:22
Size: 3093
Editor: hd
Comment:
Revision 5 as of 2004-09-07 15:27:54
Size: 4286
Editor: hd
Comment:
Deletions are marked like this. Additions are marked like this.
Line 21: Line 21:
当然,如果你需要定制你的world你可以学习一下我的/etc/make.conf文件:
{{{
CPUTYPE=i686

NO_FORTRAN= true # do not build g77 and related libraries
NO_I4B= true # do not build isdn4bsd package
NO_LPR= true # do not build lpr and related programs
NO_SENDMAIL= true # do not build sendmail and related programs
NO_SHAREDOCS= true # do not build the 4.4BSD legacy docs
NO_X= true # do not compile in XWindows support (e.g. doscmd)
NOGAMES= true # do not build games (games/ subdir)
NOINFO= true # do not make or install info files
NOPERL= true # do not build perl. Disables OpenSSL optimizations
NOPROFILE= true # Avoid compiling profiled libraries
NOUUCP= true # do not build uucp related programs
}}}
Line 30: Line 46:
}} }}}
Line 82: Line 98:

== 尾记 ==
jail是一个非常有用的工具,你可以将其使用在多种环境之下,它比简单的chroot强大,因为它可以完成一个主机的功能,比vmware轻巧,因为它的硬盘和内存使用都是真正的共享,而且不消耗CPU。如果你是BSDer哪么一定要试试它,相信会给你带来很多的方便和惊喜。

-- hd [DateTime(2004-08-08T18:04:09Z)] TableOfContents

Freebsd Jail安装Howto

呵呵,安装系统总是很烦的,为了实现“五分钟安装一台Server”,我告诉大家使用jail来驱动freebsd的决胜大法。

make jail world

需要先为vhost准备一个目录:

mkdir –p /home/jail/hdtest

没有make world过

如果你从没有做过make world,哪么你只能这样:

cd /usr/src
make world DESTDIR=/home/jail/hdtest

你会发现需要一个很久的时间的。 当然,如果你需要定制你的world你可以学习一下我的/etc/make.conf文件:

CPUTYPE=i686

NO_FORTRAN=    true    # do not build g77 and related libraries
NO_I4B=        true    # do not build isdn4bsd package
NO_LPR=        true    # do not build lpr and related programs
NO_SENDMAIL=   true    # do not build sendmail and related programs
NO_SHAREDOCS=  true    # do not build the 4.4BSD legacy docs
NO_X=          true    # do not compile in XWindows support (e.g. doscmd)
NOGAMES=       true    # do not build games (games/ subdir)
NOINFO=        true    # do not make or install info files
NOPERL=        true    # do not build perl. Disables OpenSSL optimizations
NOPROFILE=     true    # Avoid compiling profiled libraries
NOUUCP=        true    # do not build uucp related programs

听说并且make world过

呵呵,如果你听说并且make world过,哪么你是幸福的人,而且真的就可以五分钟就安装完这个系统了:

cd /usr/src
make installworld DESTDIR=/home/jail/hdtest
cd /usr/src/etc
make distribution DESTDIR=/home/jail/hdtest

准备vhost使用的地址

你可以手工临时的启动一个alias的ip地址:

ifconfig fxp0 inet 192.168.10.60 netmask 255.255.255.255

这里fxp0换成你的网卡,ip换成你的ip。但是临时的方法并不好,将这行加入到/etc/rc.conf中去罢:

ifconfig_fxp0_alias0="inet 192.168.10.60 netmask 255.255.255.255"

对vhost实施外科手术

这个vhost还缺少很多的东东,我们为它进行一个外科手术:

mkdir /home/jail/hdtest/stand
cp /stand/sysinstall /home/jail/hdtest/stand/
cp /etc/resolv.conf /home/jail/hdtest/etc
touch /home/jail/hdtest/etc/fstab

这里主要是复制sysinstall系统工具以及将dns配置、fstab默认配置生成,由于vhost不需要自己的文件系统,所以fstab将是一个空的文件。

进入vhost的单用户模式

先进行vhost的单用户模式,给vhost进行相应的配置:

jail /home/jail/hdtest jail.huangdong.com 192.168.10.60 /bin/sh

这里jail.huangdong.com是你的hostname,192.168.10.60是你的ip地址,这个ip地址应该已经使用alias参数绑定在你的网卡上。最后的/bin/sh是进去后运行的shell。需要注意的是/bin/sh这是vhost中的路径,大家不要当成了host中的路径。

配置vhost

进入vhost的单用户模式后,你就得到一个在vhost中的shell,这时你可以执行sysinstall工具:

/stand/sysinstall

以下是我一定会配置的内容,建议你配置,当然你也可以自己选择:

  • Console中将Repeat设置为fast
  • User Management中加入系统中的用户(记得要加一个wheel能su成root的用户哟)
  • Time Zone中设置正确的时区
  • Networking中设置inetd为no、Mail为None、并选中sshd(inetd和sshd为必须)
  • Startup中关了quotas

配置完成后输入:

exit

退出单用户模式。

启动vhost

一切都完成后,只需要在命令行输入:

jail /home/jail/test jail.huangdong.com 192.168.10.60 /bin/sh /etc/rc

这样你就启动了一个真正的vhost,它开启了sshd服务,通过你的ssh2客户端登录上去试试罢。看看五分钟的装机是否成功。

尾记

jail是一个非常有用的工具,你可以将其使用在多种环境之下,它比简单的chroot强大,因为它可以完成一个主机的功能,比vmware轻巧,因为它的硬盘和内存使用都是真正的共享,而且不消耗CPU。如果你是BSDer哪么一定要试试它,相信会给你带来很多的方便和惊喜。

bsd/JailInstallHowto (last edited 2009-12-25 07:15:41 by localhost)