部署PXE服务器
PXE(预启动执行环境,在操作系统之前运行)是由Intel公司开发的网络引导技术,工作在Client/Server模式,允许客户机通过网络从远程服务器下载引导镜像,并加载安装文件或者整个操作系统。
安装软件包
yum install dhcp tftp-server httpd syslinux -y
配置dhcp服务器
vim /etc/dhcp/dhcpd.conf
# A slightly different configuration for an internal subnet.
subnet 192.168.150.0 netmask 255.255.255.0 {
range 192.168.150.5 192.168.150.100;
default-lease-time 7200;
filename "pxelinux.0";
next-server 192.168.150.130;
}
配置tftp服务器
vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
systemctl start tftp.socket
systemctl status tftp.socket
systemctl enable tftp.socket
拷贝pxe配置文件到/var/lib/tftpboot/
复杂引导文件
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
复杂菜单文件
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
复制系统iso进行中的引导文件
cp /iso/centos7/isolinux/vmlinuz /var/lib/tftpboot/
cp /iso/centos7/isolinux/initrd.img /var/lib/tftpboot/
[root@PXE-Server tftpboot]# ll
总用量 57820
-rw-r--r-- 1 root root 52893200 3月 3 14:23 initrd.img
-rw-r--r-- 1 root root 55140 3月 3 14:20 menu.c32
-rw-r--r-- 1 root root 26759 3月 3 14:19 pxelinux.0
-rwxr-xr-x 1 root root 6224704 3月 3 14:23 vmlinuz
制作安装菜单文件,default文件
cd /var/lib/tftpboot/pxelinux.cfg/
[root@PXE-Server pxelinux.cfg]# cat default
default menu.c32
timeout 300
prompt 0
label 1
menu label ^1) Install CentOS7
menu default
kernel vmlinuz
append initrd=initrd.img method=http://192.168.150.130/Centos7 ks=http://192.168.150.130/ks.cfg
default文件
[root@PXE-Server pxelinux.cfg]# cat default
default menu.c32
timeout 300
##自动使用标记2的引导文件
default 2
prompt 0
label 1
menu label ^1) Install CentOS7
kernel vmlinuz
append initrd=initrd.img method=http://192.168.150.130/Centos7 ks=http://192.168.150.130/ks.cfg
label 1
menu label ^1) Install CentOS7
kernel vmlinuz
append initrd=initrd.img method=http://192.168.150.130/Centos7 ks=http://192.168.150.130/ks.cfg
[root@localhost html]# vim ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url http://192.168.100.99/Centos7
#cdrom
# Use graphical install
#graphical
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
#network --bootproto=dhcp --device=ens34 --onboot=off --ipv6=auto
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$Kpvt9o9VbrsruMFF$AWfNRZ5aGsq0flAPkknpcEPjHDbB9QRda287SSgR4dvBwb0xtZaCt7u1iM0kDnEqQmDrFbADDEUEmvQwCrfka/
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel
%packages
@^minimal
@core
chrony
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
reboot
配置http服务器,通过http访问iso文件
把安装iso的文件拷贝到html目录
通过http://IP/Centos7
cd /var/www/html/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」