PXE——安装,配置,测试(rhel7环境下)

发布于:2024-08-08 ⋅ 阅读:(109) ⋅ 点赞:(0)

什么是PXE

        PXE(Preboot eXecution Environment,预启动执行环境)允许计算机在开机时从网络而非本地硬盘或其他存储设备启动。这种技术主要用于网络启动和自动化安装系统,尤其在需要为大量计算机同时安装操作系统的情况下非常有用。

安装需求

  • VMware虚拟机
  • rhel7镜像

VMware安装虚拟机

   可参照以下链接http://t.csdnimg.cn/urI7dicon-default.png?t=N7T8http://t.csdnimg.cn/urI7d

安装所需软件 

sudo yum install -y dhcp tftp-server httpd syslinux system-config-kickstart

查看本机IP和网关

本机ip: 

[root@192 ~]# hostname -i
192.168.242.131

本机网关:

[root@192 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.242.2   0.0.0.0         UG    100    0        0 ens33
192.168.242.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

配置HTTPD

mount /rhel7 /var/www/html/rhel7

配置DHCP服务

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 114.114.114.114;

default-lease-time 600;
max-lease-time 7200;

# 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.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.
subnet 192.168.242.0 netmask 255.255.255.0{
  range 192.168.242.50 192.168.242.60;
  option routers 192.168.242.2;
  next-server 192.168.242.131;
  filename "pxelinux.0";
}
#重启dhcp服务
systemctl restart dhcpd

配置TFTP服务

#启动tftp服务
systemctl enable --now tftp
#挂载本地镜像
mkdir /rhel7
mount /dev/sr0 /rhel7
cp /rhel7/isolinux/*  /var/lib/tftpboot/
cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
cd /var/lib/tftpboot/
mkdir pxelinux.cfg
cp isolinux.cfg pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
#配置文件如下
default vesamenu.c32
timeout 30

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Red Hat Enterprise Linux 7.9
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label linux
  menu label ^Install Red Hat Enterprise Linux 7.9
  menu default
  kernel vmlinuz
  append initrd=initrd.img http://192.168.242.131/rhel7 ks=http://192.168.242.131/ks.cfg  quiet

label check
  menu label Test this ^media & install Red Hat Enterprise Linux 7.9
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 rd.live.check quiet

menu separator # insert an empty line

# utilities submenu
menu begin ^Troubleshooting
  menu title Troubleshooting

label vesa
  menu indent count 5
  menu label Install Red Hat Enterprise Linux 7.9 in ^basic graphics mode
  text help
	Try this option out if you're having trouble installing
	Red Hat Enterprise Linux 7.9.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 xdriver=vesa nomodeset quiet

label rescue
  menu indent count 5
  menu label ^Rescue a Red Hat Enterprise Linux system
  text help
	If the system will not boot, this lets you access files
	and edit config files to try to get it booting again.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 rescue quiet

label memtest
  menu label Run a ^memory test
  text help
	If your system is having issues, a problem with your
	system's memory may be the cause. Use this utility to
	see if the memory is working correctly.
  endtext
  kernel memtest

menu separator # insert an empty line

label local
  menu label Boot from ^local drive
  localboot 0xffff

menu separator # insert an empty line
menu separator # insert an empty line

label returntomain
  menu label Return to ^main menu
  menu exit

menu end

配置kickstart

#启动工具(要安装图像界面)
system-config-kickstart

 

cp /root/ks.cfg /var/www/html

 关闭防火墙selinux启动并启用dhcp,tftp,http服务

sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo setenforce 0
sudo systemctl start dhcpd tftp httpd
sudo systemctl enable dhcpd tftp httpd

测试

 

等待安装,安装完成别忘记把bios里改成硬盘启动


网站公告

今日签到

点亮在社区的每一天
去签到