免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3096 | 回复: 1
打印 上一主题 下一主题

[cobbler] 通过Cobbler实现自动化安装FreeBSD [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-09-11 15:08 |只看该作者 |倒序浏览
1. 挂载FreeBSD镜像
  1. mount -t iso9660 -o loop FreeBSD-8.3-RELEASE-amd64-disc1.iso  /mnt
复制代码
2. 导入镜像文件到Cobbler
  1. cobbler import --name=FreeBSD-8.3 --arch=x86_64 --path=/mnt
  2. 我们在导入过程中可能会提示TASK FAILED
复制代码


可以忽略

3. 修改loader.conf
  1. echo vfs.root.mountfrom=\"ufs:/dev/md0\" >> /var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/loader.conf
  2. echo vfs.root.mountfrom.options=\"rw\" >> /var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/loader.conf
复制代码
4. 挂载mfsroot.gz
  1. 将/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/mfsroot.gz拷贝到一台FreeBSD机器上后,执行如下命令
  2. gzip -d mfsroot.gz
  3. mdconfig -atvnode -f mfsroot
  4. mount /dev/md0 /mnt
复制代码
5. 建立自动安装配置文件install.cfg
  1. cd /mnt
  2. cat > install.cfg < < EOF
  3. debug=YES
  4. nonInteractive=YES
  5. noConfirm=YES
  6. noWarn=YES
  7. disk=mfid0
  8. partition=all
  9. bootManager=standard
  10. diskPartitionEditor
  11. mfid0s1-1=ufs 0 /
  12. diskLabelEditor
  13. tryDHCP=YES
  14. netDev=bce0
  15. hostname=tFreeBSD
  16. distSetMinimum
  17. nfs=1.1.1.1:/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64
  18. mediaSetNFS
  19. installCommit
  20. shutdown
  21. EOF
复制代码
6. 将install.cfg合并到mfsroot
  1. cd ~
  2. umount /mnt
  3. mdconfig -d -u0
  4. gzip mfsroot
  5. 再通过网络传输到Cobbler服务器覆盖原/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64/boot/目录下的mfsroot.gz文件
复制代码
7. 安装配置nfs服务器
  1. # 默认FreeBSD的网络引导程序pxeboot只支持nfs,如果想支持tftp需要自行重新编译这个程序
  2. yum install -y nfs-utils
  3. echo "/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64 *(ro,root_squash)" > /etc/exports
  4. /etc/init.d/rpcbind start
  5. /etc/init.d/nfs start
复制代码
8. 更改Cobbler的dhcp模板文件dhcp.template
  1. # ******************************************************************
  2. # Cobbler managed dhcpd.conf file
  3. #
  4. # generated from cobbler dhcp.conf template ($date)
  5. # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
  6. # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
  7. # overwritten.
  8. #
  9. # ******************************************************************

  10. ddns-update-style interim;
  11. ignore client-updates;
  12. deny unknown-clients;
  13. allow booting;
  14. allow bootp;

  15. ignore client-updates;
  16. set vendorclass = option vendor-class-identifier;

  17. subnet 192.168.2.0 netmask 255.255.255.0 {
  18.      option routers             192.168.2.1;
  19.      option domain-name-servers 192.168.2.12;
  20.      option subnet-mask         255.255.255.0;
  21.      # range dynamic-bootp        192.168.2.235 192.168.2.236;
  22.      # filename                   "/pxelinux.0";
  23.      filename                   "/images/FreeBSD-8.3-x86_64/pxeboot";
  24.      option root-path           "192.168.2.134:/var/www/cobbler/ks_mirror/FreeBSD-8.3-x86_64";
  25.      default-lease-time         21600;
  26.      max-lease-time             43200;
  27.      group pxe {
  28.           next-server                192.168.2.134;
  29.           host test{
  30.                hardware ethernet 11:11:11:11:11:11;
  31.                fixed-address 192.168.2.235;
  32.           }
  33.      }
  34. }

  35. #for dhcp_tag in $dhcp_tags.keys():
  36.     ## group could be subnet if your dhcp tags line up with your subnets
  37.     ## or really any valid dhcpd.conf construct ... if you only use the
  38.     ## default dhcp tag in cobbler, the group block can be deleted for a
  39.     ## flat configuration
  40. # group for Cobbler DHCP tag: $dhcp_tag
  41. group {
  42.         #for mac in $dhcp_tags[$dhcp_tag].keys():
  43.             #set iface = $dhcp_tags[$dhcp_tag][$mac]
  44.     host $iface.name {
  45.         hardware ethernet $mac;
  46.         #if $iface.ip_address:
  47.         fixed-address $iface.ip_address;
  48.         #end if
  49.         #if $iface.hostname:
  50.         option host-name "$iface.hostname";
  51.         #end if
  52.         #if $iface.netmask:
  53.         option subnet-mask $iface.netmask;
  54.         #end if
  55.         #if $iface.gateway:
  56.         option routers $iface.gateway;
  57.         #end if
  58.         #if $iface.enable_gpxe:
  59.         if exists user-class and option user-class = "gPXE" {
  60.             filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
  61.         } else {
  62.             filename "undionly.kpxe";
  63.         }
  64.         #else
  65.         filename "$iface.filename";
  66.         #end if
  67.         ## Cobbler defaults to $next_server, but some users
  68.         ## may like to use $iface.system.server for proxied setups
  69.         next-server $next_server;
  70.         ## next-server $iface.next_server;
  71.     }
  72.         #end for
  73. }
  74. #end for
复制代码
9. 同步Cobbler配置
  1. cobbler sync
复制代码
现在就可以通过网络自动安装FreeBSD系统了

论坛徽章:
0
2 [报告]
发表于 2012-09-12 15:15 |只看该作者
支持一下,很不错的分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP