说明:
服务端:Kickstart server
Os:centos5
Software:dhcp,tftp,nfs
Ip:10.10.10.2/255.255.255.0
Gw:none
客户端:
只需要支持pxe启动既可
安装DHCP,TFTP,NFS
(1)( 将CentOS-5.2-x86_64-bin-DVD.iso的光盘镜像挂载到/media/CentOS目录下,命令如:mount 镜像目录/CentOS-5.2-x86_64-bin-DVD.iso /media/CentOS -o loop。)
mount CentOS-5.2-i386-bin-DVD.iso /media/CentOS -o loop
(2)( 禁用/etc/yum.repo.d/CentOS-Base.repo中的源,激活/etc/yum.repo.d/CentOS-Media.repo中的安装源(即禁用联网源,改为使用光盘镜像作为源)。)
yum --disablerepo=\* --enablerepo=c5-media -y install dhcp* nfs* tftp*
(3)禁用防火墙和SELINUX
Service iptables stop
SELINUX=disabled
配置DHCP
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 10.10.10.0 netmask 255.255.255.0 {
option routers 10.10.10.2;
option subnet-mask 255.255.255.0;
option domain-name-servers 10.10.10.2;
option time-offset -18000;
range dynamic-bootp 10.10.10.100 10.10.10.150;
default-lease-time 21600;
max-lease-time 43200;
# Group the PXE bootable hosts together
# PXE-specific configuration directives...
next-server 10.10.10.2;
filename "/pxelinux.0";
}
配置完成之后,重启DHCP服务:service dhcpd restart
将DHCP服务设为开机自动启动:chkconfig dhcpd on
配置TFTP
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
配置完成之后,重启xinet服务:service xinetd restart
将xinetd设置为开机自动启动:chkconfig xinetd on
配置NFS
echo "/tftpboot *(ro,sync)" >> /etc/exports
echo "/media/CentOS *(ro,sync)" >> /etc/exports #此二步设置共享的目录
exportfs -a #使配置生效
/etc/init.d/portmap start &&/etc/init.d/nfs start #重启服务
chkconfig nfs on
showmount –e localhost #看查共享的目录
Export list for localhost:
/tftpboot *
/media/CentOS *
配置pxe所需要的文件
mkdir /tftpboot/pxelinux.cfg
mkdir /tftpboot/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
cp /media/CentOS/isolinux/vmlinuz /tftpboot/
cp /media/CentOS/isolinux/initrd.img /tftpboot/
cp /media/CentOS/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
修改:/tftpboot/pxelinux.cfg/default内容为:
[root@kickstart tftpboot]# more /tftpboot/pxelinux.cfg/default
default ks
label ks
kernel vmlinuz
append initrd=initrd.img ksdevice=eth0 ks=nfs:10.10.10.1:/tftpboot/ks.cfg
注:ksdevice=eth0 这一句可以指定由哪一个网卡安装,对于多网卡的机器用。
创建/tftpboot/ks.cfg文件
# Kickstart file automatically generated by anaconda.
install
nfs --server=10.10.10.2 --dir=/media/CentOS
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp --hostname kickstart
rootpw --iscrypted $1$kE50pGl1$imqt12NcqN6KiJGToKNZo0
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda
# 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 --initlabel
part /boot --fstype ext3 --size=100
part swap --size=1024
part / --fstype ext3 --size=1 --grow
%packages
@development-libs
@core
@base
@development-tools
device-mapper-multipath
imake
客户端安装
将客户端设定为从网络启动,启动后将会进入自动安装系统界面。
注,如果需要自动化安装多种定制系统,可以定制多种ks.cfg,那么需要做些稍微的调整,首先:
(1)[root@kickstart tftpboot]# more pxelinux.cfg/default
default ks
prompt 1
timeout 60
display boot.msg <=cp /media/CentOS/isolinux/boot.msg /tftpboot/
label ks
kernel vmlinuz
append initrd=initrd.img ksdevice=eth0 ks=nfs:10.10.10.1:/tftpboot/ks.cfg<=针对多网卡
label ks1
kernel vmlinuz
append initrd=initrd.img ks=nfs:10.10.10.1:/tftpboot/ks1.cfg <-针对单网卡
(2)boot.msg
^L
^Xsplash.lss
- To install first mode, press the <ENTER> key or type: ks <ENTER> .
- To install second mode, type: ks1 <ENTER> .
Welcome to use kickstart! By-zhuzhengjun
(3)在tftpboot目录下创建多个ks.cfg文件
(3)在tftpboot目录下创建多个ks.cfg文件
本文转自hahazhu0634 51CTO博客,原文链接:http://blog.51cto.com/5ydycm/344097,如需转载请自行联系原作者