kickstart远程安装自动Centos 5.7 32bit系统,经过几十次重启调试,全自动安装终于做通。难点主要是在ks.cfg 配置文件上。稍有错误,安装过程就变成手动了。测试表明,使用redhat的system-config-kickstart工具生成的配置文件不太给力,中途需要手动,所以还是自己手动改比较好。这样可用加深对配置文件的理解。网上有很多类似文章,但要真正掌握,定制自己想要的,还是要亲自折腾下。
环境【Centos 5.7 32bit apache httpd* dhcp tftp* xinetd*】
一、安装kickstart需要的软件包
- #yum -y install httpd* dhcp tftp* xinetd*
二、配置web服务器
- #vim /etc/httpd/conf/httpd.conf
- 查找deny字段改为:
- allow from all
三、挂载并拷贝镜像到apache网站根目录
- #mount /dev/cdrom /media
- #cp -r /media/* /var/www/html
四、配置DHCP服务,根据实际情况修改ip相关参数
- #vim /etc/dhcpd.conf
- ddns-update-style interim;
- allow booting;
- allow bootp;
- ignore client-updates;
- set vendorclass = option vendor-class-identifier;
- subnet 192.168.217.0 netmask 255.255.255.0 {
- option routers 192.168.217.130; #你的服务器IP
- #option domain-name-servers 192.168.217.2;
- option subnet-mask 255.255.255.0;
- range dynamic-bootp 192.168.217.200 192.168.217.254;
- filename "/pxelinux.0";
- default-lease-time 21600;
- max-lease-time 43200;
- next-server 192.168.217.130;
- }
- # group for Cobbler DHCP tag: default
- group {
- }
五、配置tftp,修改disable参数为no
- #vim /etc/xinetd.d/tftp
- disable = no
六、配置tftpboot
- #cd /tftpboot/ ————>若该文件夹已经存在则不用建立
- #cp /usr/lib/syslinux/pxelinux.0 /tftpboot
- #cp /var/www/html/p_w_picpaths/pxeboot/initrd.img /tftpboot
- #cp /var/www/html/p_w_picpaths/pxeboot/vmlinuz /tftpboot
- #cp /var/www/html/isolinux/*.msg /tftpboot
- #在tftpboot中新建一个pxelinux.cfg目录
- #mkdir /tftpboot/pxelinux.cfg
把Linux安装光盘上isolinux目录中的isolinux.cfg复制到pxelinux.cfg目录中,并同时更改文件名称为default
- cp /var/www/html/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
修改default文件,第一行添加ks.cfg访问地址。如下,其中timeout选项可设为“1”,这个是引导时等待用户手动选择的时间,设为“1”直接引导。
- default text ks=http://192.168.217.130/ks.cfg
- prompt 1
- timeout 1
启动相关服务
- chkconfig httpd on
- service httpd restart
- chkconfig dhcpd on
- service dhcpd restart
- chkconfig tftp on
- service xinetd restart
七、配置kickstart文件,亲测配置文件,多次修改,完全可用。
- #cd /var/www/html
- #touch ks.cfg
- #chmod 755 ks.cfg
- #vim ks.cfg
- # Kickstart file automatically generated by anaconda.
- install
- #http --server=192.168.217.130 --dir=/
- url --url http://192.168.217.130/
- lang en_US.UTF-8
- keyboard us
- text
- bootloader --location=mbr
- #Clear the Master Boot Record
- zerombr yes
- 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
- #network --device eth0 --bootproto dhcp
- rootpw 000000
- firewall --disabled
- authconfig --enableshadow --enablemd5
- selinux --enforcing
- timezone --utc Asia/Chongqing
- bootloader --location=mbr --driveorder=sda
- clearpart --all --initlabel
- # The following is the partition information you requested
- # Note that any partitions you deleted are not expressed
- # here so unless you clear all partitions first, this is
- # not guaranteed to work
- #clearpart --all --drives=sda
- part /boot --fstype ext3 --size=100
- part / --fstype ext3 --size=3000
- part swap --size=512
- part /data --fstype ext3 --size=1 --grow
- reboot
- skipx
- %packages --resolvedeps
- @base
- @development-tools @development-libs
- keyutils
- iscsi-initiator-utils
- trousers
- fipscheck
- device-mapper-multipath
- imake
- %post
- echo "nameserver 61.139.2.69" >> /etc/resolv.conf
- /sbin/chkconfig microcode_ctl off
- /sbin/chkconfig lvm2-monitor off
- /sbin/chkconfig readahead_early off
- /sbin/chkconfig kudzu off
- /sbin/chkconfig mcstrans off
- /sbin/chkconfig isdn off
- /sbin/chkconfig auditd off
- /sbin/chkconfig restorecond off
- /sbin/chkconfig cpuspeed off
- /sbin/chkconfig irqbalance off
- /sbin/chkconfig ip6tables off
- /sbin/chkconfig portmap off
- /sbin/chkconfig nfslock off
- /sbin/chkconfig mdmonitor off
- /sbin/chkconfig rpcidmapd off
- /sbin/chkconfig rpcgssd off
- /sbin/chkconfig messagebus off
- /sbin/chkconfig bluetooth off
- /sbin/chkconfig netfs off
- /sbin/chkconfig pcscd off
- /sbin/chkconfig acpid off
- /sbin/chkconfig apmd off
- /sbin/chkconfig haldaemon off
- /sbin/chkconfig hidd off
- /sbin/chkconfig autofs off
- /sbin/chkconfig cups off
- /sbin/chkconfig rawdevices off
- /sbin/chkconfig sendmail off
- /sbin/chkconfig gpm off
- /sbin/chkconfig anacron off
- /sbin/chkconfig atd off
- /sbin/chkconfig yum-updatesd off
- /sbin/chkconfig avahi-daemon off
- /sbin/chkconfig firstboot off
- /sbin/chkconfig local off
- /sbin/chkconfig smartd off
八、开机从网卡引导,约5分钟完成安装。
鸣谢:参考黄大师配置http://hxl2009.blog.51cto.com
转载于:https://blog.51cto.com/xikder/789413