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/images/pxeboot/initrd.img /tftpboot
- #cp /var/www/html/images/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