1. 挂载FreeBSD镜像

mount -t iso9660 -o loop FreeBSD-8.3-RELEASE-amd64-disc1.iso  /mnt

2. 导入镜像文件到Cobbler

cobbler import --name=FreeBSD-8.3 --arch=x86_64 --path=/mnt

我们在导入过程中可能会提示TASK FAILED

 

 

可以忽略

3. 修改loader.conf

 

echo vfs.root.mountfrom=\"ufs:/dev/md0\" >> /var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/loader.conf

echo vfs.root.mountfrom.options=\"rw\" >> /var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/loader.conf

4. 挂载mfsroot.gz

 

将/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/mfsroot.gz拷贝到一台FreeBSD机器上后,执行如下命令

gzip -d mfsroot.gz

mdconfig -atvnode -f mfsroot

mount /dev/md0 /mnt

5. 建立自动安装配置文件install.cfg

 

cd /mnt

cat > install.cfg < < EOF

debug=YES

nonInteractive=YES

noConfirm=YES

noWarn=YES

disk=mfid0

partition=all

bootManager=standard

diskPartitionEditor

mfid0s1-1=ufs 0 /

diskLabelEditor

tryDHCP=YES

netDev=bce0

hostname=tFreeBSD

distSetMinimum

nfs=1.1.1.1:/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64

mediaSetNFS

installCommit

shutdown

EOF

 

6. 将install.cfg合并到mfsroot

 

cd ~

umount /mnt

mdconfig -d -u0

gzip mfsroot

再通过网络传输到Cobbler服务器覆盖原/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/目录下的mfsroot.gz文件

 

7. 安装配置nfs服务器

 

# 默认FreeBSD的网络引导程序pxeboot只支持nfs,如果想支持tftp需要自行重新编译这个程序

yum install -y nfs-utils

echo "/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64 *(ro,root_squash)" > /etc/exports

/etc/init.d/rpcbind start

/etc/init.d/nfs start

 

8. 更改Cobbler的dhcp模板文件dhcp.template

 

# ******************************************************************

# Cobbler managed dhcpd.conf file

#

# generated from cobbler dhcp.conf template ($date)

# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes

# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be

# overwritten.

#

# ******************************************************************

 

ddns-update-style interim;

ignore client-updates;

deny unknown-clients;

allow booting;

allow bootp;

 

ignore client-updates;

set vendorclass = option vendor-class-identifier;

 

subnet 192.168.2.0 netmask 255.255.255.0 {

     option routers             192.168.2.1;

     option domain-name-servers 192.168.2.12;

     option subnet-mask         255.255.255.0;

     # range dynamic-bootp        192.168.2.235 192.168.2.236;

     # filename                   "/pxelinux.0";

     filename                   "/p_w_picpaths/FreeBSD-8.3-x86_64/pxeboot";

     option root-path           "192.168.2.134:/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64";

     default-lease-time         21600;

     max-lease-time             43200;

     group pxe {

          next-server                192.168.2.134;

          host test{

               hardware ethernet 11:11:11:11:11:11;

               fixed-address 192.168.2.235;

          }

     }

}

 

#for dhcp_tag in $dhcp_tags.keys():

    ## group could be subnet if your dhcp tags line up with your subnets

    ## or really any valid dhcpd.conf construct ... if you only use the

    ## default dhcp tag in cobbler, the group block can be deleted for a

    ## flat configuration

# group for Cobbler DHCP tag: $dhcp_tag

group {

        #for mac in $dhcp_tags[$dhcp_tag].keys():

            #set iface = $dhcp_tags[$dhcp_tag][$mac]

    host $iface.name {

        hardware ethernet $mac;

        #if $iface.ip_address:

        fixed-address $iface.ip_address;

        #end if

        #if $iface.hostname:

        option host-name "$iface.hostname";

        #end if

        #if $iface.netmask:

        option subnet-mask $iface.netmask;

        #end if

        #if $iface.gateway:

        option routers $iface.gateway;

        #end if

        #if $iface.enable_gpxe:

        if exists user-class and option user-class = "gPXE" {

            filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";

        } else {

            filename "undionly.kpxe";

        }

        #else

        filename "$iface.filename";

        #end if

        ## Cobbler defaults to $next_server, but some users

        ## may like to use $iface.system.server for proxied setups

        next-server $next_server;

        ## next-server $iface.next_server;

    }

        #end for

}

#end for

 

9. 同步Cobbler配置

cobbler sync