yum -y install tftp* yum -y install dhcp* yum -y install httpd* yum -y install system-config-kickstart yum -y install syslinux
2.1 创建tftp文件夹:
mkdir -p /tftpboot
2.2 将centos 6.4 x86_6的iso挂载到/mnt下:
mount -t iso9660 /dev/cdrom /mnt/
2.3 复制光盘里的文件:
cp /mnt/images/pxeboot/* /tftpboot
2.4 复制光盘里的isolinux
cp /mnt/isolinux/*.* /tftpboot
2.5复制pxelinux.0
cp /usr/share/syslinux/pxelinux.0 /tftpboot
2.6创建文件夹:
mkdir -p /tftpboot/pxelinux.cfg
2.7 复制配置文件:
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
2.8 复制dhcpd配置文件:
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcpd/dhcpd.conf
2.9 复制所有的iso 文件到httpd的首页目录:
cp -rf /mnt/* /var/www/html/
3.1 修改tfpt 启动文件项目
vim /etc/xinetd.d/tftp ----------------------------------------------------------------------- # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot ### 这里改成tftp的文件存放路径,此处为/tftpboot/ disable = no ### 把yes 改成 no , 开启tftp的启动 per_source = 11 cps = 100 2 flags = IPv4 }
service xinetd restart
vim /etc/dhcp/dhcpd.conf -------------------------------------------------------------------------------------------------------------------------------------------------------------- ddns-update-style none; #改成none ignore client-updates; next-server 192.168.80.150; #dhcp服务器地址 filename "/pxelinux.0"; # 手动添加这行 >否则不能启动安装 subnet 192.168.80.0 netmask 255.255.255.0 { option routers 192.168.80.254; option subnet-mask 255.255.255.0; option nis-domain "che100.org"; option domain-name "che100.org"; option domain-name-servers 8.8.8.8; option time-offset -18000; range dynamic-bootp 192.168.80.151 192.168.80.153; # 可分配地址空间 default-lease-time 21600; max-lease-time 43200; }
service dhcpd restart
5.1运行system-config-kickstart
system-config-kickstart
2设置dhcp的访问地址
3 设置grub 和内核部分:
4 定义分区方式:
5 添加自己的网络设备
6
7防火墙和selinux的初始化选项,这里全都是禁止使用:
8 图形配置的禁用
9 软件包的选择:
10 预安装脚本的添加处:
11安装后需要执行脚本的添加:
12 保存ks.conf 到网站跟目录。
配置完成 选择界面 file --- save --- 保存到httpd的主目录。我的默认在/var/www/html/ 下名称为ks.cfg
注意:在11步的时候需要添加如下的系统服务优化代码:
for name in `chkconfig --list | grep 3:on | awk '{print $1}'`;do chkconfig --level 3 $name off;done for name in crond network rsyslog sshd;do chkconfig --level 3 $name on;done for name in `chkconfig --list | grep 5:on | awk '{print $1}'`;do chkconfig --level 5 $name off;done for name in crond network rsyslog sshd;do chkconfig --level 5 $name on;done
service httpd restart service xinetd restart service dhcpd restart
----------------------------------------------至此system-config-kickstart 配置完成--------------------------------------------------------------------
vim /tftpboot/pxelinux.cfg/default ------------------------------------------------------------------------------------------------------------------------------------------------- default vesamenu.c32 #prompt 1 timeout 3 display boot.msg menu background splash.jpg menu title Welcome to CentOS 6.4! menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000 label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append initrd=initrd.img append ks=http://192.168.80.150/ks.cfg initrd=initrd.img biosdevname=0 ksdevice=eth0 ### 如果这行不存在要添加这行“192.168.80.150”是dhcp服务器地址,后面全都需要 label menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img xdriver=vesa nomodeset label rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff label memtest86 menu label ^Memory test kernel memtest append -
访问ks.cfg文件,看看是否可以访问到ks.cfg文件的所有内容:
1 开始pxe 启动寻找dhcp服务器
######################################至此客户端测试完毕#######################################
vim /tftpboot/pxelinux.cfg/default append ks=http://192.168.80.150/ks.cfg initrd=initrd.img biosdevname=0 ksdevice=eth0 解决办法: 增加 biosdevname=0 网上很多文章说这个地方有没有无所谓,虚拟机测试的时候确实没有问题.但是到了真实环境和生产环境问题还是很大的 必须要有.谁也不想自己熟悉的eth0 变成 em1 吧!
vim /tftpboot/pxelinux.cfg/default append ks=http://192.168.80.150/ks.cfg initrd=initrd.img biosdevname=0 ksdevice=eth0 解决办法: 增加 ksdevice=eth0