安装前准备:关闭防火墙和SELINUX,DHCP服务器静态IP。
切勿用桥接模式 最好是NET模式而且把自动分配DHCP对勾取消。


查看防火墙和seelinux是否关闭

[root@centos8 ~]#firewall-cmd --state
not running
[root@centos8 ~]#getenforce
Disabled

安装对应的软件包


安装syslinux的时候centos8和centos7存在一点不同在后面的后缀-nonlinux
启动相应的三个服务 但是由于dhcp的文件配置还没有配置,所以这里起不来。

[root@centos8 ~]#ss -ntulp
查看对应端口号

![在这里插入图片描述](https://img-blog.csdnimg.cn/20191114145943475.png

开启HTTP服务

把光盘仓库挂载到web上面 同时做好的应答文件和初始化脚本也可以一起挂载上去

[root@centos8 ~]#cd /var/www/html/[root@centos8 html]#mkdir centos/{6,7,8}/isos/x86_64/ -pv
mkdir: created directory 'centos'
mkdir: created directory 'centos/6'
mkdir: created directory 'centos/6/isos'
mkdir: created directory 'centos/6/isos/x86_64/'
mkdir: created directory 'centos/7'
mkdir: created directory 'centos/7/isos'
mkdir: created directory 'centos/7/isos/x86_64/'
mkdir: created directory 'centos/8'
mkdir: created directory 'centos/8/isos'
mkdir: created directory 'centos/8/isos/x86_64/'[root@centos8 html]#tree
.
└── centos├── 6│   └── isos│       └── x86_64├── 7│   └── isos│       └── x86_64└── 8└── isos└── x86_6410 directories, 0 files
[root@centos8 html]#mount /dev/sr0 centos/8/isos/x86_64/
mount: /var/www/html/centos/8/isos/x86_64: WARNING: device write-protected, mounted read-only.
[root@centos8 html]#df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          910228       0    910228   0% /dev
tmpfs             924716       0    924716   0% /dev/shm
tmpfs             924716   17508    907208   2% /run
tmpfs             924716       0    924716   0% /sys/fs/cgroup
/dev/nvme0n1p2 104806400 4768644 100037756   5% /
/dev/nvme0n1p3  52403200  398588  52004612   1% /data
/dev/nvme0n1p1    999320  131252    799256  15% /boot
tmpfs             184940       4    184936   1% /run/user/0
/dev/sr0         6967726 6967726         0 100% /var/www/html/centos/8/isos/x86_64
[root@centos8 html]#ls
centos
[root@centos8 html]#mkdir ksdir
[root@centos8 html]#cd ksdir/

把ks8.cfg应答文件拷贝到这个目录下面

[root@centos8 ksdir]#ls
ks8.cfg
[root@centos8 ksdir]#vim ks8.cfg # Use graphical install
#repo --name="Appstream"  --baseurl=http://192.168.39.8/centos/8/isos/x86_64/AppStream
url --url=http://192.168.32.8/centos/8/isos/x86_64/
#repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
# Use CDROM installation media
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8# Network information
network  --bootproto=dhcp --device=ens160 --ipv6=auto --activate
network  --hostname=centos8.kaivi
# Root password
rootpw --iscrypted $6$OOwmaN2kXda4dp0t$oMs3ggugp0xuMknu6TqFyoZNPfka4LDIPftfqn1rrfkNmiQEJtUGPmvU2CbPjo0cvovkt4vBLIQPdb7Uz7vNe1
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --name=wang --password=$6$oUfb/02CWfLb5l8f$sgEZeR7c7DpqfpmFDH6huSmDbW1XQNR4qKl2EPns.gOXqlnAIgv9pTogtFVaDtEpMOC.SWXKYqxfVtd9MCwxb1 --iscrypted --gecos="wang"
# Disk partitioning information
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024%packages
@^minimal-environment
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end%post
curl http://192.168.32.8/reset |bash
yum install vim -y
"ks8.cfg" 60L, 1805C

把脚本也放在共享服务器上面,这里注意应答文件ks8.cfg中安装后脚本的路径要保持一致

[root@centos8 ~]#cd /var/www/html/
[root@centos8 html]#ls
centos  ksdir
[root@centos8 html]#cp /data/init.sh ./reset
cp: overwrite './reset'? y
[root@centos8 html]#ls
centos  ksdir  reset




可以正常访问,http服务正常

配置tftp服务

[root@centos8 ksdir]#cd /var/lib/tftpboot/
[root@centos8 tftpboot]#rpm -ql syslinux-nonlinux
查找对应的安装包文件。这里我们需要/usr/share/syslinux/menu.c32和/usr/share/syslinux/pxelinux.0
拷贝到 /var/lib/tftpboot/内
[root@centos8 tftpboot]#cp /usr/share/syslinux/menu.c32 .
[root@centos8 tftpboot]#cp /usr/share/syslinux/pxelinux.0 .
[root@centos8 tftpboot]#ls
menu.c32  pxelinux.0

还需要对应的内核启动文件,这些文件在光盘里面有,可以直接拷贝过来

[root@centos8 tftpboot]#ls /var/www/html/centos/8/isos/x86_64/isolinux/
boot.cat  grub.conf   isolinux.bin  ldlinux.c32   libutil.c32  splash.png  vesamenu.c32
boot.msg  initrd.img  isolinux.cfg  libcom32.c32  memtest      TRANS.TBL   vmlinuz[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/vmlinuz .
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/initrd.img .
[root@centos8 tftpboot]#ls
initrd.img  menu.c32  pxelinux.0  vmlinuz

创建一个新的文件夹 pxelinux.cfg,里面用于放置菜单配置文件

[root@centos8 tftpboot]#mkdir pxelinux.cfg
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/isolinux.cfg pxelinux.
pxelinux.0    pxelinux.cfg/
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/isolinux.cfg pxelinux.
pxelinux.0    pxelinux.cfg/
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/isolinux.cfg pxelinux.cfg/default
拷贝过来改名为default[root@centos8 tftpboot]#vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600menu title CentOS Linux 8label linuxmenu label ^Auto Install CentOS Linux 8.0 minikernel vmlinuzappend initrd=initrd.img ks=http://192.168.32.8/ksdir/ks8.cfglabel manualmenu label ^Manual Install CentOS Linux 8.0kernel vmlinuzappend initrd=initrd.img inst.repo=http://192.168.32.8/centos/8/isos/x86_64/menu separator # insert an empty linelabel localmenu defaultmenu label Boot from ^local drivelocalboot 0xffff
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/ldlinux.c32 .
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/libutil.c32 .
[root@centos8 tftpboot]#cp /var/www/html/centos/8/isos/x86_64/isolinux/libcom32.c32 .
centos 7上面以上三个可以不要  但是centos8上面对于上面三个文件有一定的依赖性,所以也要一起拷贝过来
[root@centos8 tftpboot]#tree
.
├── initrd.img
├── ldlinux.c32
├── libcom32.c32
├── libutil.c32
├── menu.c32
├── pxelinux.0
├── pxelinux.cfg
│   └── default
└── vmlinuz1 directory, 8 files

到这里tftp服务就配置好了

配置DHCP服务

[root@centos8 tftpboot]#systemctl start dhcpd
Job for dhcpd.service failed because the control process exited with error code.
See "systemctl status dhcpd.service" and "journalctl -xe" for details.
报错是因为没有配置/etc/dhcp/dhcpd.conf 这个文件暂时为空。需要复制参考文件
[root@centos8 tftpboot]#cp /usr/share/doc/dhcp-server/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite '/etc/dhcp/dhcpd.conf'? y[root@centos8 tftpboot]#vim /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 180.76.76.76, 114.114.114.114;default-lease-time 84600;
max-lease-time 100000;# 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.# This is a very basic subnet declaration.subnet 192.168.32.0 netmask 255.255.255.0 {range 192.168.32.100 192.168.32.200;option routers 192.168.32.2;next-server 192.168.32.8;filename "pxelinux.0";
}
~

重启服务即可

[root@centos8 ~]#systemctl restart dhcpd
[root@centos8 ~]#systemctl status dhcpd
● dhcpd.service - DHCPv4 Server DaemonLoaded: loaded (/usr/lib/systemd/system/dhcpd.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2019-11-14 14:12:29 CST; 5s agoDocs: man:dhcpd(8)man:dhcpd.conf(5)Main PID: 10692 (dhcpd)Status: "Dispatching packets..."Tasks: 1 (limit: 11377)Memory: 5.1MCGroup: /system.slice/dhcpd.service└─10692 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pidNov 14 14:12:29 centos8 dhcpd[10692]: ** Ignoring requests on virbr0.  If this is not what
Nov 14 14:12:29 centos8 dhcpd[10692]: you want, please write a subnet declaration
Nov 14 14:12:29 centos8 dhcpd[10692]: in your dhcpd.conf file for the network segment
Nov 14 14:12:29 centos8 dhcpd[10692]: to which interface virbr0 is attached. **
Nov 14 14:12:29 centos8 dhcpd[10692]:
Nov 14 14:12:29 centos8 dhcpd[10692]: Listening on LPF/eth0/00:0c:29:fe:da:42/192.168.32.0/24
Nov 14 14:12:29 centos8 dhcpd[10692]: Sending on   LPF/eth0/00:0c:29:fe:da:42/192.168.32.0/24
Nov 14 14:12:29 centos8 dhcpd[10692]: Sending on   Socket/fallback/fallback-net
Nov 14 14:12:29 centos8 dhcpd[10692]: Server starting service.
Nov 14 14:12:29 centos8 systemd[1]: Started DHCPv4 Server Daemon.
[root@centos8 ~]#

PEX自动化安装就配置好了

安装新系统

现在去安装一个新的centos8的系统

选择菜单


安装成功

脚本运行成功

扩展同时配置加载安装centos6 和 centos 7

需要安装什么系统,对应的光盘同样需要挂载上去

查看web服务器上是否挂载

现在配置应答文件,这里用之前已经做好的应答文件

[root@centos8 html]#cd /var/www/html/
[root@centos8 html]#ls
centos  ksdir  reset
[root@centos8 html]#cd ksdir/
[root@centos8 ksdir]#ls
ks8.cfg
[root@centos8 ksdir]#rz -E
rz waiting to receive.
[root@centos8 ksdir]#ls
ks6.cfg  ks7.cfg  ks8.cfg

修改对应的应答文件 特别是注意路径

[root@centos8 ksdir]#vim ks7.cfg
[root@centos8 ksdir]#vim ks6.cfg
[root@centos8 ksdir]#ll
-rw-r--r-- 1 root root 1235 Nov 14 16:13 ks6.cfg
-rw-r--r-- 1 root root 1435 Nov 14 16:09 ks7.cfg
-rw-r--r-- 1 root root 1805 Nov 14 14:35 ks8.cfg


在网页需要分别能打开对应的应答文件,不然就是权限问题 需要设置一下权限

设置tftp配置文件

[root@centos8 tftpboot]#ls
initrd.img  ldlinux.c32  libcom32.c32  libutil.c32  menu.c32  pxelinux.0  pxelinux.cfg  vmlinuz

创建分别放置不同操作系统的目录6 7 8.用来放置不同的内核文件

[root@centos8 tftpboot]#mkdir {6,7,8}
[root@centos8 tftpboot]#mv vmlinuz initrd.img 8/[root@centos8 tftpboot]#cp /var/www/html/centos/7/isos/x86_64/isolinux/vmlinuz ./7/
[root@centos8 tftpboot]#cp /var/www/html/centos/7/isos/x86_64/isolinux/initrd.img ./7/[root@centos8 tftpboot]#cp /var/www/html/centos/6/isos/x86_64/isolinux/vmlinuz ./6/
[root@centos8 tftpboot]#cp /var/www/html/centos/6/isos/x86_64/isolinux/initrd.img ./6/
[root@centos8 tftpboot]#tree
.
├── 6
│   ├── initrd.img
│   └── vmlinuz
├── 7
│   ├── initrd.img
│   └── vmlinuz
├── 8
│   ├── initrd.img
│   └── vmlinuz
├── ldlinux.c32
├── libcom32.c32
├── libutil.c32
├── menu.c32
├── pxelinux.0
└── pxelinux.cfg└── default4 directories, 12 files

修改菜单项 注意路径 是相对路径

[root@centos8 tftpboot]#vim pxelinux.cfg/default default menu.c32
timeout 600menu title CentOS Linuxlabel linux8menu label Auto Install CentOS Linux ^8.0 minikernel 8/vmlinuzappend initrd=8/initrd.img ks=http://192.168.32.8/ksdir/ks8.cfglabel linux7menu label Auto Install CentOS Linux ^7.0 minikernel 7/vmlinuzappend initrd=7/initrd.img ks=http://192.168.32.8/ksdir/ks7.cfglabel linux6menu label Auto Install CentOS Linux ^6.0 minikernel 6/vmlinuzappend initrd=6/initrd.img ks=http://192.168.32.8/ksdir/ks6.cfglabel manualmenu label Manual Install CentOS Linux 8.0kernel vmlinuzappend initrd=initrd.img inst.repo=http://192.168.32.8/centos/8/isos/x86_64/menu separator # insert an empty linelabel localmenu defaultmenu label Boot from ^local drivelocalboot 0xffff

参考文献如下


PXE自动化安装CentOS 8相关推荐

  1. pxe安装linux dhcp失败,利用PXE自动化安装Centos时启动DHCP服务时遇到错误,请求大佬指教...

    @利用PXE自动化安装Centos时启动DHCP服务时遇到错误,请求大佬指教 [root@localhost ~]# systemctl start dhcpd.service Job for dhc ...

  2. CentOS 6.5自动化运维之基于DHCP和TFTP服务的PXE自动化安装centos操作系统详解

    前言    如果要给很多台客户端主机安装操作系统,要是每一台都拿张安装光盘一台一台主机的去装系统那就太浪费时间和精力了.在生产环境中也不实际,要实现为多台主机自动安装操作系统,那我们怎么实现自动化安装 ...

  3. windows pxe 安装linux,菜鸟学Linux 第103篇笔记 pxe自动化安装linux

    菜鸟学Linux 第103篇笔记 pxe自动化安装linux 内容总览 linux的系统安装 kickstart文件的组成部分 DHCP (Dynamic Host Configuration Pro ...

  4. kickstart自动化系统安装_利用Kickstart自动化安装CentOS的教程

    前言 因为需要在浪潮的x86服务器中集中部署CentOS搭建基于Hadoop的大数据平台,平时接触SLES(SuSE Linux Enterprise Server)较多并且已经实现基于Autoyas ...

  5. kickstart自动化系统安装_系统运维|基于Kickstart自动化安装CentOS实践

    前言 因为需要在浪潮的x86服务器中集中部署CentOS搭建基于Hadoop的大数据平台,平时接触SLES(SuSE Linux Enterprise Server)较多并且已经实现基于Autoyas ...

  6. u盘启动pxe安装linux,U盘启动安装centos5.5+centos6.3+PXE网络安装CentOS

    此U盘启动安装盘的功能: 1.0pe可用来进行系统维护: 2.0pe可安装windows 2003原版系统: 3.0pe可作为pxe服务器进行网络安装,加上http服务器软件可提供网络安装CentOS ...

  7. linux自动化安装u盘,使用u盘自动化安装centos的例子

    使用u盘自动化安装centos的例子,供大家学习参考. 准备工作: linux镜像 windows下的syslinux.exe 1个4G的U盘(因为镜像一般都比较大) 开个虚拟机上的linux, wi ...

  8. 总结之:CentOS 6.5基于DHCP的PXE自动化安装系统详解

    前言    如果要给很多台客户端主机安装操作系统,要是每一台都拿张安装光盘一台一台主机的去装系统.那就台不现实了.在生产环境中也不会被允许的.要实现为多台主机自动安装操作系统.那我们怎么实现自动化安装 ...

  9. 使用 kickstart 半自动化安装CentOS系统 利用PXE实现自动化安装centos系统

    使用 kickstart 半自动化安装CentOS7系统 1.创建kickstart文件 创建kickstart文件的方式 可使用创建工具:system-config-kickstart ,注意:此方 ...

最新文章

  1. ASP.NET 2.0的异步页面刷新真给劲
  2. linux下创建新用户以及删除
  3. boost::parameter::aux::maybe相关的测试程序
  4. 防火墙(16)——SNAT和DNAT,DNAT实践
  5. 新建虚拟机与window的连接
  6. wordpress漏洞_用软件工具扫描WordPress / Shopify主题恶意代码以及漏洞分析相关工具...
  7. PL/SQL Developer 使用技巧小结(转)
  8. debian 删除mysql数据库_Debian中完全卸载MySQL的方法
  9. ApacheCN JavaWeb 译文集 20211017 更新
  10. 北京大学生物信息学(转录组)
  11. 图书管理系统C语言课程设计
  12. 随机课堂、随机提问、随机抽检、随机名单,可去重可重复
  13. 现在Web前端培训,哪个机构比较好?
  14. 做python少儿编程教程-基于海龟编辑器python少儿编程
  15. 观李永乐《皇帝的新衣》后感以及红蓝眼悖论解题思路
  16. 腾讯云安装mysql_详解腾讯云CentOS7.0使用yum安装mysql及使用遇到的问题
  17. LAB颜色空间各通道的取值范围
  18. R绘图 第十篇:绘制散点图(高级)
  19. 二分查找法和Fibonacci查找
  20. flask读书笔记-flask web开发

热门文章

  1. 智慧园区建设三个方面
  2. 字体包和字体子集制作,位图字体制作工具推荐
  3. 信用有多重要?买房办理不了贷款你就明白了!
  4. 信息安全入门系列——介绍
  5. vant-ui+HBuilderX快速开发APP
  6. VB基础版版务处理_20050126
  7. word2003如何设置护眼模式_word功能应用:如何进入深色护眼阅读模式
  8. 用javascript编写网页:1.2css实践:页面布局
  9. 爱米云共享网盘linux,Cozy Drive下载-云盘同步程序 v3.27.0 官方版 - 下载吧
  10. OA平台——协同管理与办公自动化