在Linux环境中,PXE(Preboot Execution Environment)是一种用于从网络启动计算机的技术。它允许客户端计算机在启动过程中从网络上的服务器(通常是DHCP、TFTP和HTTP服务器)下载操作系统映像或启动加载程序,而不是从本地硬盘或光驱启动。这使得大规模部署操作系统、进行快速恢复或维护变得非常简单和高效。
主要步骤:
1,rhel7主机
克隆虚拟机7,设置其地址172.25.254.100 用户名 pxe.yxy.org
[root@nginx ~]# vmset.sh eth0 172.25.254.100 pxe.yxy.org
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
[root@nginx ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.254.100 netmask 255.255.255.0 broadcast 172.25.254.255
inet6 fe80::20c:29ff:febf:64eb prefixlen 64 scopeid 0x20<link>
2,开启主机图形
[root@nginx ~]# ls /root/
anaconda-ks.cfg initial-setup-ks.cfg 公共 模板 视频 图片 文档 下载 音乐 桌面
[root@nginx ~]# cat /root/anaconda-ks.cfg
//此文件是系统安装好以后自动生成的,且这个文件记录了系统在安装过程中的所有设定
[root@nginx ~]# yum install system-config-kickstart -y
//安装图形化生成kickstart自动安装脚本的工具
[root@nginx ~]# system-config-kickstart
//开启图形制作工具
开始配置:
3,配置网络可用
[root@nginx ~]# mkdir /var/www/html -p
[root@nginx ~]# ln -s /rhel7/ /var/www/html
[root@nginx ~]# cd /var/www/html/
[root@nginx html]# ls
rhel7
[root@nginx ~]# vim ks.cfg
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=512
part / --fstype="xfs" --grow --size=1
%packages
%base
httpd
%end
%post
mkdir -p /rhel7
[root@nginx ~]# ksvalidator ks.cfg
[root@nginx ~]# yum install dhcp -y
[root@nginx ~]# rpm -qc dhcp
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.leases
[root@nginx ~]# \cp -f /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@nginx ~]# vim /etc/dhcp/dhcpd.conf
[root@nginx ~]# systemctl enable --now dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
[root@nginx ~]# yum install httpd -y
已安装:
httpd.x86_64 0:2.4.6-95.el7
作为依赖被安装:
apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-95.el7
mailcap.noarch 0:2.1.41-2.el7
完毕!
[root@nginx ~]# systemctl restart httpd.service
[root@nginx ~]# cd /var/www/html/
[root@nginx html]# ls
rhel7
[root@nginx html]# cd
[root@nginx ~]# cp ks.cfg /var/www/html/
[root@nginx ~]# cd /var/www/html/
[root@nginx html]# ls
ks.cfg rhel7
4,关闭vmware dhcp功能
安装一个新的虚拟机,并进行前期小测试。
这几欧克了,继续
[root@nginx ~]# yum install syslinux.x86_64 -y
[root@nginx ~]# yum install tftp-server.x86_64 -y
//共享pxelinux.0数据文件的网络服务
[root@nginx ~]# rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot //要使用此目录
[root@nginx ~]# systemctl enable --now tftp
[root@nginx ~]# vim /etc/dhcp/dhcpd.conf
[root@nginx ~]# systemctl enable --now dhcpd
[root@nginx tftpboot]# vim /var/lib/tftpboot/pxelinux.cfg/default
测试机:
测试 :