环境:
Centos 6.8服务器一台,提供FTP、DHCP和镜像安装源
未安装系统的客户机一台
步骤:
1、关闭Selinux、firewall
[root@localhost ~]# vi /etc/selinux/config
SELINUX=enforcing ###将enforcing 修改为disable
[root@localhost ~]# service iptables stop ###停止防止墙服务
[root@localhost ~]# chkconfig iptables off ###关闭开机自启
2、关闭NetworkManger
[root@localhost ~]# service NetworkManager stop ###停止NetworkManger服务
[root@localhost ~]# chkconfig NetworkManager off ###禁止NetworkManger开机自动
3、安装DHCP服务并配置
配置好YUM源
[root@localhost yum.repos.d]# yum install -y dhcp
[root@localhost ~]# cp -p /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp:是否覆盖"/etc/dhcp/dhcpd.conf"?
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers 192.168.1.1;
next-server 192.168.1.11;
filename “pxelinux.0”;
default-lease-time 86400;
max-lease-time 86400;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.100;
option routers 192.168.1.1;
}
[root@localhost dhcp]# service dhcpd restart
正在启动 dhcpd: [确定]
[root@localhost dhcp]# chkconfig dhcpd on
4、安装ftp服务并配置
[root@localhost /]# yum install -y tftp-server xinetd vsftpd
[root@localhost /]# 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 /var/lib/tftpboot
disable = no ####此处将原来的yes改为no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@localhost /]# service xinetd start
正在启动 xinetd: [确定]
[root@localhost /]# chkconfig xinetd on
[root@localhost /]# service vsftpd start
为 vsftpd 启动 vsftpd: [确定]
[root@localhost /]# chkconfig vsftpd on
5、安装syslinux、system-config-kickstart
syslinux 提供pxenux.0软件
system-config-kickstart 提供kickstart 软件
[root@localhost /]# yum install -y syslinux system-config-kickstart
6、拷贝相应文件并创建pxlinux.cfg文件
[root@localhost /]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost /]# cp /mnt/cdrom/isolinux/vmlinuz /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/initrd.img /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/boot.cat /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/boot.msg /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/vesamenu.c32 /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/splash.jpg /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/isolinux.bin /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/memtest /var/lib/tftpboot/
[root@localhost /]# cp /mnt/cdrom/isolinux/TRANS.TBL /var/lib/tftpboot/
[root@localhost /]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
vmlinuz:内核,提供驱动和识别代码
initrd.img:提供根镜像底部命令
boot.cat:菜单格式
boot.msg:菜单消息
vesamenju.c32:菜单颜色
splash.jgp:菜单背景
isolinux.bin:GRUB引导程序的前身
memtest:内存检测
TRANS.TBL:
pxelinux.0:pxeclient用于提供给pxelinux.0做程序交接
[root@localhost /]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost /]# cp -p /mnt/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot//pxelinux.cfg/default
[root@localhost /]# vi /var/lib/tftpboot//pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 600 ####此处为启动菜单等待操作时间,默认为60S
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.8!
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 ks=ftp://192.168.1.11/ks/s.cfg #### ks配置文件存放位置
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img 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 -
[root@localhost /]# chmod 777 /var/lib/tftpboot/pxelinux.cfg/default
7、配置kickstart应答文件并配置
[root@localhost /]# system-config-kickstart
[root@localhost /]# mount /dev/cdrom /var/ftp/pub
[root@localhost /]# mkdir /var/ftp/ks
[root@localhost /]# cp /root/ks.cfg /var/ftp/ks/
[root@localhost /]# chmod 777 /var/ftp/ks/ks.cfg
[root@localhost /]# cat /var/lib/tftpboot/pxelinux.cfg/default | grep ks
append initrd=initrd.img ks=ftp://192.168.1.11/ks/ks.cfg
8、客户机开机