1.安装软件

(1)dhcp

(2)tftp

(3)xinetd

(4)nfs

2.安装:

yum -y install dhcp
yum -y install tftp-server
yum -y install tftp
yum -y install xinetd
yum -y install syslinux
yum -y install nfs*

3.修改配置

修改dhcp配置

vim /etc/dhcpd.conf

ddns-update-style interim;
ignore client-updates;
next-server 192.168.0.2;
filename "pxelinux.0";
subnet 192.168.0.0 netmask 255.255.0.0 {
    option time-offset      -18000; # Eastern Standard Time
    range dynamic-bootp 192.168.250.2 192.168.250.254;
    default-lease-time 21600;
    max-lease-time 43200;
}


修改tftp配置:

sed -i "s/disable.*/disable = no/"  /etc/xinetd.d/tftp
sed -i "s/server_args.*/server_args     = -s \/tftpboot/"  /etc/xinetd.d/tftp


创建目录:

mkdir -p  /tftpboot/p_w_picpaths/centos/${system_version}/x86

将pxelinux.0放到/tftpboot目录


启动服务:

service dhcpd restart
service xinetd restart
service portmap start
service nfslock start
service nfs start


修改nfs配置并测试:

echo '/netinstall/kickstart    *(ro,async)'> /etc/exports
echo "/tftpboot/p_w_picpaths/centos/${system_version}/x86  *(ro,async)">>/etc/exports
exportfs -rv
showmount -e $ip


将iso镜像放到/root目录并挂载同步p_w_picpath文件:


wget -T 5 -t 2 -O /root/CentOS-${system_version}-x86_64-bin-DVD.iso http://${downloadserver1}/CentOS-${system_version}-x86_64-bin-DVD.iso
mount -o loop /root/CentOS-${system_version}-x86_64-bin-DVD.iso  /tftpboot/p_w_picpaths/centos/${system_version}/x86
rsync -av /tftpboot/p_w_picpaths/centos/${system_version}/x86/p_w_picpaths/pxeboot/*  /tftpboot/

添加默认文件:


mkdir -p /tftpboot/pxelinux.cfg
touch /tftpboot/pxelinux.cfg/default
echo "default linux" >/tftpboot/pxelinux.cfg/default
echo "prompt 0" >>/tftpboot/pxelinux.cfg/default
echo "label linux">>/tftpboot/pxelinux.cfg/default
echo "kernel p_w_picpaths/centos/${system_version}/x86/isolinux/vmlinuz">>/tftpboot/pxelinux.cfg/default
    echo "append ks=nfs:${ip}:/netinstall/kickstart/ks.cfg initrd=p_w_picpaths/centos/${system_version}/x86/isolinux/initrd.img">>/tftpboot/pxelinux.cfg/defaulttian



添加ks.cfg

wget -T 5 -t 2 -O /netinstall/kickstart/ks.cfg http://${downloadserver1}/ks.cfg-${system_version}
chmod 644 /netinstall/kickstart/ks.cfg
sed -i "s/nfs --server=/nfs --server=${ip}/" /netinstall/kickstart/ks.cfg
sed -i "s/5.5/${system_version}/" /netinstall/kickstart/ks.cfg