背景:
阅读新闻
PXE+Kickstart安装CentOS 7.3
[日期:2017-06-14] 来源:Linux社区 作者:xiong51 [字体:]
Linux系统版本:CentOS 7.3
软件版本:yum epel源
主机IP: 192.168.8.35
需要软件:tftp-server dhcp syslinux xinetd system-config-kickstart nginx
[root@node1 ~]# yum -y install tftp-server dhcp syslinux xinetd system-config-kickstart
[root@node1 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@node1 ~]# vim /etc/dhcp/dhcpd.conf # 添加如下行
subnet 192.168.8.0 netmask 255.255.255.0 {
option routers 192.168.8.35;
range 192.168.8.103 192.168.8.200;
option domain-name-servers 192.168.8.35;
filename "pxelinux.0";
next-server 192.168.8.35;
default-lease-time 600;
max-lease-time 7200;
}
# 改完之后重新dhcpd
# 命令详解
# option routers dhcp路由地址
# range dhcp分配地址池
# default-lease-time dhcp默认时长
# filename pxe服务名称
# next-server pxe服务器地址
# allow members pxe最大值
vim /etc/xinetd.d/tftp
disable = no
# 将disable 改为no 改完之后重新瞬间守护进程
# 配置nginx
[root@node1 ~]# vim /etc/nginx/nginx.conf 添加一个server段
server {
listen 80;
server_name 192.168.8.35;
location / {
root /mnt/cdrom;
autoindex on;
}
location /ks {
alias /var/lib/tftpboot;
autoindex on;
}
}
[root@node1 cdrom]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@node1 cdrom]# cp /mnt/cdrom/isolinux/boot.msg /var/lib/tftpboot/
[root@node1 cdrom]# cp /mnt/cdrom/isolinux/vesamenu.c32 /var/lib/tftpboot/
[root@node1 cdrom]# cp /mnt/cdrom/isolinux/splash.png /var/lib/tftpboot/
[root@node1 ~]# cp /mnt/cdrom/images//pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
[root@node1 ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@node1 ~]# cp /mnt/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@node1 ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
label linux Centos 7.2
menu label ^Install Centos 7.2 system
menu default
kernel vmlinuz
append initrd=initrd.img inst.ks=http://192.168.8.35/ks/ks.cfg quiet
[root@node1 ~]# systemctl restart xinetd.service
[root@node1 ~]# systemctl restart dhcpd.service
[root@node1 ~]# systemctl restart nginx
# 挂载光盘镜像至/opt/cdrom以下的格式必须为[development] 否则将报错
# yum源 格式强制 否则会报软件无法加载错误
[development]
name=yum
baseurl=file:///mnt/cdrom/
enable=1
gpgcheck=0
[epel]
name=epel_rpm
baseurl=http://192.168.9.19:81/epel7/
enable=1
gpgcheck=0
# 安装kickstart软件包配置启动文件
[root@node1 ~]# system-config-kickstart