批量安装从4.2至8.1版本的freebsd [2010年]:
  前提条件是有freebsd安装源,pxe或U盘(U盘上拷了光盘镜像),通过脚本选择不同的发布版本安装。

  所有演示均在实验环境中,而非生产环境。

图1 下图是通过pxe的boot过程


图2 通过NFS boot启动一个高版本freebsd,用以灌入其它版本。


图3 通过终端远程登录,选择安装版本,并且以脚本进行安装。


图4 脚本在安装前会自动检查硬件和核对MAC地址表取得配置,并列表出来,这个列表可以手工修改。


运行过程中按分区策略分区和格式化硬盘后,mount光盘镜像文件,开始灌入系统,
灌入系统后,运行post install安装一些预置的包,过程中这些包提示要改某处的配置,不要理它,
最后一步会写入这些配置。

下面是运行过程:

9 Mar 15:27:24 ntpdate[1361]: no server suitable for synchronization found
1024+0 records in
1024+0 records out
1048576 bytes transferred in 9.083862 secs (115433 bytes/sec)
******* Working on device /dev/da0 *******
fdisk: invalid fdisk partition table found
fdisk: Class not found
/dev/da0s1a: 1024.0MB (2097152 sectors) block size 16384, fragment size 2048
        using 6 cylinder groups of 183.72MB, 11758 blks, 23552 inodes.
super-block backups (for fsck -b #) at:
 160, 376416, 752672, 1128928, 1505184, 1881440
/dev/da0s1d: 384.0MB (786432 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 96.02MB, 6145 blks, 12352 inodes.
        with soft updates
super-block backups (for fsck -b #) at:
 160, 196800, 393440, 590080
/dev/da0s1e: 128.0MB (262144 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 32.02MB, 2049 blks, 4160 inodes.
        with soft updates
super-block backups (for fsck -b #) at:
 160, 65728, 131296, 196864
Reduced frags per cylinder group from 94064 to 94048 to enlarge last cyl group
/dev/da0s1f: 22784.0MB (46661564 sectors) block size 16384, fragment size 2048
        using 125 cylinder groups of 183.69MB, 11756 blks, 23552 inodes.
        with soft updates
super-block backups (for fsck -b #) at:
 160, 376352, 752544, 1128736, 1504928, 1881120, 2257312, 2633504, 3009696, 3385888, 3762080, 4138272, 4514464,
 4890656, 5266848, 5643040, 6019232, 6395424, 6771616, 7147808, 7524000, 7900192, 8276384, 8652576, 9028768,
 9404960, 9781152, 10157344, 10533536, 10909728, 11285920, 11662112, 12038304, 12414496, 12790688, 13166880,
 13543072, 13919264, 14295456, 14671648, 15047840, 15424032, 15800224, 16176416, 16552608, 16928800, 17304992,
 17681184, 18057376, 18433568, 18809760, 19185952, 19562144, 19938336, 20314528, 20690720, 21066912, 21443104,
 21819296, 22195488, 22571680, 22947872, 23324064, 23700256, 24076448, 24452640, 24828832, 25205024, 25581216,
 25957408, 26333600, 26709792, 27085984, 27462176, 27838368, 28214560, 28590752, 28966944, 29343136, 29719328,
 30095520, 30471712, 30847904, 31224096, 31600288, 31976480, 32352672, 32728864, 33105056, 33481248, 33857440,
 34233632, 34609824, 34986016, 35362208, 35738400, 36114592, 36490784, 36866976, 37243168, 37619360, 37995552,
 38371744, 38747936, 39124128, 39500320, 39876512, 40252704, 40628896, 41005088, 41381280, 41757472, 42133664,
 42509856, 42886048, 43262240, 43638432, 44014624, 44390816, 44767008, 45143200, 45519392, 45895584, 46271776,
 46647968
mount source from 192.168.10.102:/fs_ro/freebsd/freebsd81
Extracting base...
Extracting catpages...
Extracting dict...
Extracting doc...
Extracting info...
Extracting manpages...
Extracting lib32...
Extracting proflibs...
Extracting sources into /tmp/root/usr/src...
  Extracting source component: base
  Extracting source component: bin
  Extracting source component: cddl
  Extracting source component: contrib
  Extracting source component: crypto
  Extracting source component: etc
  Extracting source component: games
  Extracting source component: gnu
  Extracting source component: include
  Extracting source component: krb5
  Extracting source component: lib
  Extracting source component: libexec
  Extracting source component: release
  Extracting source component: rescue
  Extracting source component: sbin
  Extracting source component: secure
  Extracting source component: share
  Extracting source component: sys
  Extracting source component: tools
  Extracting source component: ubin
  Extracting source component: usbin
Done extracting sources.
Installing kernel...
Configurating...
install on da0
#############################
# install package.          #
#############################

/etc/mail/aliases: 27 aliases, longest 10 bytes, 275 bytes total
chpass: user information updated
Removing stale symlinks from /usr/bin...
    Skipping /usr/bin/perl
    Skipping /usr/bin/perl5
Done.
Creating various symlinks in /usr/bin...
    Symlinking /usr/local/bin/perl5.10.1 to /usr/bin/perl
    Symlinking /usr/local/bin/perl5.10.1 to /usr/bin/perl5
Done.
Cleaning up /etc/make.conf... Done.
Spamming /etc/make.conf... Done.
Cleaning up /etc/manpath.config... Done.
Spamming /etc/manpath.config... Done.

**** This port installs snmp daemon, header files and libraries but don't
     invokes snmpd by default.
     If you want to invoke snmpd and/or snmptrapd at startup, put these
     lines into /etc/rc.conf.

        snmpd_enable="YES"
        snmpd_flags="-a"
        snmpd_conffile="/usr/local/share/snmp/snmpd.conf /etc/snmpd.conf"
        snmptrapd_enable="YES"
        snmptrapd_flags="-a -p /var/run/snmptrapd.pid"

**** You may specify the following make variables:

        NET_SNMP_SYS_CONTACT="[email protected]"
        NET_SNMP_SYS_LOCATION="Brasilia, BRA"
        DEFAULT_SNMP_VERSION=3
        NET_SNMP_MIB_MODULES="host smux mibII/mta_sendmail ucd-snmp/diskio"
        NET_SNMP_LOGFILE=/var/log/snmpd.log
        NET_SNMP_PERSISTENTDIR=/var/net-snmp

     to define default values (or overwriting defaults).  At least
     setting first two variables, you will not be prompted during
     configuration process.  You may also set

        BATCH="yes"

     to avoid interactive configuration.

pkg_add: package 'libiconv-1.13.1_1' or its older version already installed

*******************************************************************************
*                                                                             *
* Do not forget to add COMPAT_FREEBSD4 into                                   *
* your kernel configuration (enabled by default).                             *
*                                                                             *
* To configure and recompile your kernel see:                                 *
* http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html *
*                                                                             *
*******************************************************************************


*******************************************************************************
*                                                                             *
* Do not forget to add COMPAT_FREEBSD5 into                                   *
* your kernel configuration (enabled by default).                             *
*                                                                             *
* To configure and recompile your kernel see:                                 *
* http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html *
*                                                                             *
*******************************************************************************


*******************************************************************************
*                                                                             *
* Do not forget to add COMPAT_FREEBSD6 into                                   *
* your kernel configuration (enabled by default).                             *
*                                                                             *
* To configure and recompile your kernel see:                                 *
* http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html *
*                                                                             *
*******************************************************************************


*******************************************************************************
*                                                                             *
* Do not forget to add COMPAT_FREEBSD7 into                                   *
* your kernel configuration (enabled by default).                             *
*                                                                             *
* To configure and recompile your kernel see:                                 *
* http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html *
*                                                                             *
*******************************************************************************


SECURITY NOTE: The VIM software has had several remote vulnerabilities
discovered within VIM's modeline support.  It allowed remote attackers to
execute arbitrary code as the user running VIM.  All known problems
have been fixed, but the FreeBSD Security Team advises that VIM users
use 'set nomodeline' in ~/.vimrc to avoid the possibility of trojaned
text files.

umount NFS source:done!
complete! Please reboot

安装完成后,用reboot重启系统。