1.查看系统版本。防火墙,selinux关闭
[[email protected] ~]# cat /etc/redhat-release
- > ## CentOS Linux release 7.2.1511 (Core)
[[email protected] ~]# getenforce
Disabled
[[email protected] ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
2.安装dhcp服务,编辑配置文件,并启动
[[email protected] ~]# yum -y install dhcp
[[email protected] ~]# cat >>/etc/dhcp/dhcpd.conf<<EOF
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.101 172.16.1.199;
option subnet-mask 255.255.255.0;
default-lease-time 21600;
max-lease-time 43200;
next-server 172.16.1.100;
filename "/pxelinux.0";
}
EOF
[[email protected] ~]# systemctl start dhcpd
dhcpd6.service dhcpd.service
[[email protected] ~]# systemctl status dhcpd
● dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2018-03-12 20:01:42 CST; 7s ago
[[email protected] ~]# netstat -tunlp|grep 67
udp 0 0 0.0.0.0:67 0.0.0.0:* 2501/dhcpd
3.安装tftp服务,并启动
[[email protected] ~]# yum -y install tftp-server
[[email protected] ~]# systemctl start tftp.socket
[[email protected] ~]# netstat -tulnp
udp6 0 0 :::69 :::* 1/systemd
4.安装syslinux,复制pxelinux.0 到tftp根目录
[[email protected] ~]# yum -y install syslinux
[[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[[email protected] ~]# ls /var/lib/tftpboot/
pxelinux.0
[[email protected] ~]# mkdir -p /var/www/html/CentOS7
[[email protected] ~]# mount /dev/cdrom /var/www/html/CentOS7/ //挂载镜像文件到http站点目录
mount: /dev/sr0 is write-protected, mounting read-only
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sr0 4.1G 4.1G 0 100% /var/www/html/CentOS7
[[email protected] ~]# cp -a /var/www/html/CentOS7/isolinux/* /var/lib/tftpboot/
[[email protected] ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg //默认找pxelinux.cfg目录下的文件,不要更改,固定目录
[[email protected] ~]# cp /var/www/html/CentOS7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[[email protected] ~]# tailf /var/log/messages
Mar 12 22:57:15 fitme dhcpd: DHCPACK on 172.16.1.101 to 00:0c:29:e9:99:40 via eth1
Mar 12 22:57:15 fitme in.tftpd[2898]: tftp: client does not accept options
Mar 12 22:57:15 fitme in.tftpd[2899]: Client ::ffff:172.16.1.101 finished /pxelinux.0
Mar 12 22:57:15 fitme in.tftpd[2910]: Client ::ffff:172.16.1.101 finished /pxelinux.cfg/default
Mar 12 22:57:15 fitme in.tftpd[2911]: Client ::ffff:172.16.1.101 finished /boot.msg
Mar 12 22:57:15 fitme in.tftpd[2913]: Client ::ffff:172.16.1.101 finished /vesamenu.c32
Mar 12 22:57:15 fitme in.tftpd[2914]: Client ::ffff:172.16.1.101 finished /pxelinux.cfg/default
Mar 12 22:57:15 fitme in.tftpd[2915]: Client ::ffff:172.16.1.101 finished /splash.png
5.安装http服务,并启动,修改default文件,安装源为http源
[[email protected] ~]# yum -y install httpd
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
63 kernel vmlinuz
64 # append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207
\x20x86_64 quiet //注释默认路径
65 append initrd=initrd.img inst.repo=http://172.16.1.100/CentOS7/ //更改为tftp目录
66
67
68 label check
=============================================
加密密码生成:
python -c ‘import crypt; print(crypt.crypt("密码"))‘
=============================================
6.编写ks自动应答文件
vi /var/www/html/ks_config/CentOS7-ks.cfg
7.编写修改启动文件
vi /var/lib/tftpboot/pxelinux.cfg/default
default ks
prompt 0
label ks
kernel vmlinuz
append initrd=initrd.img ks=http://172.16.1.100/ks_config/CentOS7-ks.cfg net.ifnames=0 biosde
vname=0 ksdevice=eth1
8.开启电源,自动安装系统
kickstart配置多客户端定制安装系统
1.获取客户端MAC地址
2.修改ks文件wei定制文件,按需定制,本例定制ip及hostname
network --bootproto=static --device=eth0 --gateway=10.0.0.254 --ip=10.0.0.8 --nameserver=223.5
.5.5 --netmask=255.255.255.0 --activate
network --bootproto=static --device=eth1 --ip=172.16.1.8 --netmask=255.255.255.0 --activate
network --hostname=web02
说明:ks文件部分语句
3.cd /var/lib/tftpboot/pxelinux.cfg
cp cp default ./01-00-50-56-3e-b6-1c
vim 01-00-50-56-3e-b6-1c
default ks
prompt 0
label ks
kernel vmlinuz
append initrd=initrd.img ks=http://172.16.1.100/ks_config/CentOS7.1-ks.cfg net.ifnames=0 bios
devname=0 ksdevice=eth1
说明:更改ks文件为定制ks文件
以mac地址命名查找,mac应为小写
kickstart完成为考试要求,推荐cobbler定制安装
原文地址:http://blog.51cto.com/674564591/2086252