FreeBSD的自动安装
折腾这个事儿很长时间了
一方面现在装FreeBSD很少
不急
所以一直也没弄好
最近快年底了,得赶紧弄完
所以今天终于搞定了
结构是局域网上有一台install server
上面开着ftp、tftp服务
要装的机器pxe去抓tftp上的启动image启动机器
然后用户输入装机用的网络设备、ip、掩码、网关、dns服务器
然后系统就自动去ftp server上抓东西安装
安装完毕
自动重起
文件install.cfg的内容:
debug=yes
command=sh /stand/setmedia.sh
system
configFile=/stand/setmedia.cfg
loadConfig
文件setmedia.sh的内容:
#!/bin/sh
set PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/sbin
export PATH
tmpfile=/stand/install.tmp
config=/stand/setmedia.cfg
#menu=/stand/menu.cfg
menu=""eval icount=0
for i in `ifconfig -l`; do
menu="${menu}${i} ${i} "
# echo -n "$i $i " >> ${menu}
icount=$((${icount} + 1))
done
if [ -z "${iface}" ]; then
dialog –title "Select Install Interface" \
–menu "Please select the network interface for install you with to perform." \
-1 -1 ${icount} `echo ${menu}` 2>${tmpfile}
read iface < ${tmpfile}
rm -f ${tmpfile}
fi
if [ -z "${ip}" ]; then
dialog –title "Input IP Address" \
–inputbox "Please input the ip address of ${iface} for install you with to perform." \
-1 -1 2>${tmpfile}
read ip < ${tmpfile}
rm -f ${tmpfile}
fi
if [ -z "${netmask}" ]; then
dialog –title "Input Netmask" \
–inputbox "Please input the netmask of the network." \
-1 -1 2>${tmpfile}
read netmask < ${tmpfile}
rm -f ${tmpfile}
fi
if [ -z "${gateway}" ]; then
dialog –title "Input Gateway" \
–inputbox "Please input the default gateway of the network." \
-1 -1 2>${tmpfile}
read gateway < ${tmpfile}
rm -f ${tmpfile}
fi
if [ -z "${nameserver}" ]; then
dialog –title "Input Nameserver’s IP" \
–inputbox "Please input the ip of the nameserver." \
-1 -1 2>${tmpfile}
read nameserver < ${tmpfile}
rm -f ${tmpfile}
fi
if [ -z "${server}" ]; then
dialog –title "Select Install Server" \
–menu "Please select the server you wish to install from." \
-1 -1 3 \
"192.168.222.21" "@idc1" \
"10.102.5.31" "@idc2" \
"10.1.21.49" "@office1" 2>${tmpfile}
read server < ${tmpfile}
rm -f ${tmpfile}
fi
echo "hostname=autoinst.sohu.com" >> ${config}
echo "domainname=sohu.com" >> ${config}
echo "nameserver=${nameserver}" >> ${config}
echo "defaultrouter=${gateway}" >> ${config}
echo "ipaddr=${ip}" >> ${config}
echo "netmask=${netmask}" >> ${config}
echo "" >> ${config}
echo "_ftpPath=ftp://${server}/pub/os/FreeBSD/releases/i386/4.11" >> ${config}
echo "netDev=${iface}" >> ${config}
echo "mediaSetFTP" >> ${config}
echo "distSetMinimum" >> ${config}
disks=`sysctl -n kern.disks`
if [ ! -z "${disks}" ]; then
disk=`echo ${disks} | sed -e ’s/ .*//g’`
fi
echo "disk=${disk}" >> ${config}
echo "partition=all" >> ${config}
echo "bootManager=standard" >> ${config}
echo "diskPartitionEditor" >> ${config}
echo "#diskPartitionWrite" >> ${config}
echo "${disk}s1-1=ufs 1024000 /" >> ${config}
echo "${disk}s1-2=swap 4096000 none" >> ${config}
echo "${disk}s1-3=ufs 4096000 /var" >> ${config}
echo "${disk}s1-4=ufs 2048000 /root" >> ${config}
echo "${disk}s1-5=ufs 10240000 /usr" >> ${config}
echo "${disk}s1-6=ufs 0 /opt" >> ${config}
echo "diskLabelEditor" >> ${config}
echo "installCommit" >> ${config}
echo "shutdown" >> ${config}





Discussion Area - Leave a Comment