kickstart远程安装自动Centos 5.7 32bit系统,经过几十次重启调试,全自动安装终于做通。难点主要是在ks.cfg 配置文件上。稍有错误,安装过程就变成手动了。测试表明,使用redhat的system-config-kickstart工具生成的配置文件不太给力,中途需要手动,所以还是自己手动改比较好。这样可用加深对配置文件的理解。网上有很多类似文章,但要真正掌握,定制自己想要的,还是要亲自折腾下。

环境【Centos 5.7 32bit apache httpd* dhcp tftp* xinetd*

一、安装kickstart需要的软件包

 
  
  1. #yum -y install httpd* dhcp tftp* xinetd* 

二、配置web服务器

 
  
  1. #vim /etc/httpd/conf/httpd.conf 
  2. 查找deny字段改为: 
  3. allow from all 

三、挂载并拷贝镜像到apache网站根目录

 
  
  1. #mount /dev/cdrom /media 
  2. #cp -r /media/* /var/www/html 

四、配置DHCP服务,根据实际情况修改ip相关参数

 
  
  1. #vim /etc/dhcpd.conf 
  2.   
  3. ddns-update-style interim; 
  4. allow booting; 
  5. allow bootp;  
  6. ignore client-updates; 
  7. set vendorclass = option vendor-class-identifier; 
  8. subnet 192.168.217.0 netmask 255.255.255.0 { 
  9.      option routers             192.168.217.130; #你的服务器IP
  10.      #option domain-name-servers 192.168.217.2; 
  11.      option subnet-mask         255.255.255.0; 
  12.      range dynamic-bootp        192.168.217.200 192.168.217.254
  13.      filename                   "/pxelinux.0"; 
  14.      default-lease-time         21600; 
  15.      max-lease-time             43200; 
  16.      next-server                192.168.217.130
  17. # group for Cobbler DHCP tag: default 
  18. group { 
  19.  

五、配置tftp,修改disable参数为no

 
  
  1. #vim /etc/xinetd.d/tftp 
  2. disable = no 

六、配置tftpboot

 
  
  1. #cd /tftpboot/             ————>若该文件夹已经存在则不用建立 
  2. #cp /usr/lib/syslinux/pxelinux.0 /tftpboot 
  3. #cp /var/www/html/p_w_picpaths/pxeboot/initrd.img /tftpboot 
  4. #cp /var/www/html/p_w_picpaths/pxeboot/vmlinuz /tftpboot 
  5. #cp /var/www/html/isolinux/*.msg /tftpboot 
  6. #在tftpboot中新建一个pxelinux.cfg目录   
  7. #mkdir /tftpboot/pxelinux.cfg 

把Linux安装光盘上isolinux目录中的isolinux.cfg复制到pxelinux.cfg目录中,并同时更改文件名称为default

 
  
  1. cp /var/www/html/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default 

修改default文件,第一行添加ks.cfg访问地址。如下,其中timeout选项可设为“1”,这个是引导时等待用户手动选择的时间,设为“1”直接引导。

 
  
  1. default text ks=http://192.168.217.130/ks.cfg
  2. prompt 1
  3. timeout 1

 启动相关服务

 
  
  1. chkconfig httpd on 
  2. service httpd restart 
  3. chkconfig dhcpd on 
  4. service dhcpd restart 
  5. chkconfig tftp  on 
  6. service xinetd restart 

七、配置kickstart文件,亲测配置文件,多次修改,完全可用。

 
  
  1. #cd /var/www/html 
  2. #touch ks.cfg 
  3. #chmod 755 ks.cfg 
  4. #vim ks.cfg 
  5.  
  6. # Kickstart file automatically generated by anaconda. 
  7.  
  8. install 
  9. #http --server=192.168.217.130 --dir=/ 
  10. url --url http://192.168.217.130/ 
  11. lang en_US.UTF-8 
  12. keyboard us 
  13. text 
  14. bootloader --location=mbr  
  15. #Clear the Master Boot Record 
  16. zerombr yes 
  17. network --device=eth0 --bootproto static --ip 192.168.217.136 --netmask 255.255.255.0 --gateway 192.168.217.130 --nameserver 8.8.8.8 --onboot=on --hostname test-01 
  18.  
  19. #network --device eth0 --bootproto dhcp 
  20. rootpw 000000 
  21. firewall --disabled 
  22. authconfig --enableshadow --enablemd5 
  23. selinux --enforcing 
  24. timezone --utc Asia/Chongqing 
  25. bootloader --location=mbr --driveorder=sda 
  26. clearpart --all --initlabel 
  27. # The following is the partition information you requested 
  28. # Note that any partitions you deleted are not expressed 
  29. # here so unless you clear all partitions first, this is 
  30. # not guaranteed to work 
  31. #clearpart --all --drives=sda 
  32. part /boot --fstype ext3 --size=100 
  33. part / --fstype ext3 --size=3000 
  34. part swap --size=512 
  35. part /data --fstype ext3 --size=1 --grow 
  36. reboot 
  37. skipx 
  38. %packages --resolvedeps 
  39. @base
  40. @development-tools @development-libs
  41. keyutils 
  42. iscsi-initiator-utils 
  43. trousers 
  44. fipscheck 
  45. device-mapper-multipath 
  46. imake 
  47. %post 
  48. echo "nameserver 61.139.2.69" >> /etc/resolv.conf 
  49. /sbin/chkconfig microcode_ctl off 
  50. /sbin/chkconfig lvm2-monitor off 
  51. /sbin/chkconfig readahead_early off 
  52. /sbin/chkconfig kudzu off 
  53. /sbin/chkconfig mcstrans off 
  54. /sbin/chkconfig isdn off 
  55. /sbin/chkconfig auditd off 
  56. /sbin/chkconfig restorecond off 
  57. /sbin/chkconfig cpuspeed off 
  58. /sbin/chkconfig irqbalance off 
  59. /sbin/chkconfig ip6tables off 
  60. /sbin/chkconfig portmap off 
  61. /sbin/chkconfig nfslock off 
  62. /sbin/chkconfig mdmonitor off 
  63. /sbin/chkconfig rpcidmapd off 
  64. /sbin/chkconfig rpcgssd off 
  65. /sbin/chkconfig messagebus off 
  66. /sbin/chkconfig bluetooth off 
  67. /sbin/chkconfig netfs off 
  68. /sbin/chkconfig pcscd off 
  69. /sbin/chkconfig acpid off 
  70. /sbin/chkconfig apmd off 
  71. /sbin/chkconfig haldaemon off 
  72. /sbin/chkconfig hidd off 
  73. /sbin/chkconfig autofs off 
  74. /sbin/chkconfig cups off 
  75. /sbin/chkconfig rawdevices off 
  76. /sbin/chkconfig sendmail off 
  77. /sbin/chkconfig gpm off 
  78. /sbin/chkconfig anacron off 
  79. /sbin/chkconfig atd off 
  80. /sbin/chkconfig yum-updatesd off 
  81. /sbin/chkconfig avahi-daemon off 
  82. /sbin/chkconfig firstboot off 
  83. /sbin/chkconfig local off 
  84. /sbin/chkconfig smartd off 

 八、开机从网卡引导,约5分钟完成安装。

 鸣谢:参考黄大师配置http://hxl2009.blog.51cto.com

 参考http://www.2cto.com/os/201011/77614.html