天天看点

通过Cobbler实现自动化安装FreeBSD

 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

通过Cobbler实现自动化安装FreeBSD

可以忽略

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;

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";

        #if $iface.netmask:

        option subnet-mask $iface.netmask;

        #if $iface.gateway:

        option routers $iface.gateway;

        #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";

        ## 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