当前位置:网站首页>PXE server configuration

PXE server configuration

2022-07-07 00:12:00 rtoax

PXE Server configuration

Rong Tao
2022 year 1 month 25 Japan

Document modification log

date Modify the content Modifier remarks
2022 year 1 month 25 Japan establish Rong Tao
2022 year 1 month 26 Japan PXE BIOS/UEFI Rong Tao
2022 year 1 month 27 Japan Kickstart Rong Tao
2022 year 2 month 11 Japan Add Rong Tao

introduction

PXE( Pre boot execution environment , Run before the operating system ) By Intel Network guidance technology developed by the company , Working in Client/Server Pattern , Allows clients to download boot images from remote servers over the network , And load the installation file or the entire operating system .

1. Build the conditions that need to be met

  • client
    1. The network card of the client should support PXE agreement ( Integrate BOOTROM chip ), And the motherboard supports network boot . Generally, most server hosts support , Just in BIOS Setting allows you to set from Network or LAN Start it up .
    2. Once the client is started , First to the server DHCP request IP Address , from TFTP Receive startup file .
  • Server side
    1. There's one on the Internet DHCP Server to automatically assign addresses to clients 、 Specify the boot file location .
    2. The server has to go through TFTP service ( Simple file transfer protocol ) To provide the download of system kernel and boot image files .
    3. adopt HTTP(s),FTP,NFS Provide image installation source service ;

2. PXE Installation process

  1. take ISO Mirror or install the tree to HTTP(s),FTP,NFS The server ;
  2. To configure TFTP Service and DHCP service , And in PXE Start on the server TFTP service ;
  3. Start the client and start the installation ;

GRUB2 boot loader Not only support TFTP, And support HTTP Your network starts . But use HTTP send out vmlinuz and initrd Startup file may fail , Recommended TFTP The server .

Relevant reference links :

build PXE Remote installation server

1. Based on BIOS Client configuration PXE The server

  1. install tftp
$ sudo dnf install tftp-server dhcp-server
  1. Allow access to tftp
$ sudo firewall-cmd --add-service=tftp
success
$ sudo firewall-cmd --reload
  1. Use SYSLINUX To configure DHCP service , The configuration file /etc/dhcp/dhcpd.conf The contents are as follows :
option space pxelinux;
option pxelinux.magic code 208 = string;
option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32;
option architecture-type code 93 = unsigned integer 16;

subnet 192.168.122.0 netmask 255.255.255.0 {
	  option routers 192.168.122.1;
	  range 192.168.122.221 192.168.122.224;

	  class "pxeclients" {
	  match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
	  next-server 192.168.122.22;

	  if option architecture-type = 00:07 {
        filename "BOOTX64.efi";
      } else {
	    filename "pxelinux/pxelinux.0";
	  }
	}
}

my PXE Server's IP The address is 192.168.122.22/24, Subnet mask 255.255.255.0, gateway 192.168.122.1.

Be careful : If you've already configured DHCP service , So you need to DHCP Server configuration .

  1. visit SYSLINUX Of pxelinux.0 file

First mount ISO Mirror image , And find syslinux-tftpboot Data packets ( stay ISO The path in the image may be ./AppStream/Packages/syslinux-tftpboot, without , Use syslinux-nonlinux);

  1. Then unzip it :
$ rpm2cpio syslinux-tftpboot-6.04-0.19.el9.noarch.rpm | cpio -div

The files included after decompression are as follows :

$ pwd
/home/rongtao/syslinux-tftpboot/tftpboot
$ ls
cat.c32        dir.c32       ifcpu64.c32      libmenu.c32  pcitest.c32   sysdump.c32
chain.c32      disk.c32      ifcpu.c32        libutil.c32  pmload.c32    syslinux.c32
cmd.c32        dmi.c32       ifmemdsk.c32     linux.c32    poweroff.c32  vesa.c32
cmenu.c32      dmitest.c32   ifplop.c32       lpxelinux.0  prdhcp.c32    vesainfo.c32
config.c32     elf.c32       kbdmap.c32       ls.c32       pwd.c32       vesamenu.c32
cptime.c32     ethersel.c32  kontron_wdt.c32  lua.c32      pxechn.c32    vpdtest.c32
cpu.c32        gfxboot.c32   ldlinux.c32      mboot.c32    pxelinux.0    whichsys.c32
cpuid.c32      gpxecmd.c32   lfs.c32          memdisk      reboot.c32    zzjson.c32
cpuidtest.c32  hdt.c32       libcom32.c32     meminfo.c32  rosh.c32
debug.c32      hexdump.c32   libgpl.c32       menu.c32     sanboot.c32
dhcp.c32       host.c32      liblua.c32       pci.c32      sdi.c32
  1. establish /var/lib/tftpboot/pxelinux/ Folder , Copy all the above files to /var/lib/tftpboot/pxelinux Next
$ sudo mkdir -p /var/lib/tftpboot/pxelinux
$ sudo cp /home/rongtao/syslinux-tftpboot/tftpboot/* /var/lib/tftpboot/pxelinux
  1. establish /var/lib/tftpboot/pxelinux/pxelinux.cfg/ Folder
$ sudo mkdir /var/lib/tftpboot/pxelinux/pxelinux.cfg
  1. stay /var/lib/tftpboot/pxelinux/pxelinux.cfg/ Created in default Configuration file for , The contents are as follows :
default vesamenu.c32
prompt 1
timeout 600

display boot.msg

label linux
  menu label ^Install CCLinux 2203 rc1
  menu default
  kernel images/cclinux-2203-rc1-x86_64/vmlinuz
  append initrd=images/cclinux-2203-rc1-x86_64/initrd.img ip=dhcp inst.repo=http://192.168.122.22/CCLinux-2203-x86_64-rc1/
label vesa
  menu label Install CCLinux 2203 rc1 with ^basic video driver
  kernel images/cclinux-2203-rc1-x86_64/vmlinuz
  append initrd=images/cclinux-2203-rc1-x86_64/initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://192.168.122.22/CCLinux-2203-x86_64-rc1/
label rescue
  menu label ^Rescue installed CCLinux 2203 rc1
  kernel images/cclinux-2203-rc1-x86_64/vmlinuz
  append initrd=images/cclinux-2203-rc1-x86_64/initrd.img rescue
label local
  menu label Boot from ^local drive
  localboot 0xffff

Be careful

  • There is no runtime mirror , The installer will not work . Use inst.stage2 The boot option specifies the location where the image is installed ;
  • For installation source location inst.repo Appoint , Must contain .treeinfo file ;
  • When you choose one DVD As the installation source ,.treeinfo The document points to BaseOS and AppStream Warehouse .
  • When using kickstart when , Need to add inst.ks= Options , Specific reference Kickstart Configuration documentation for ( stay /var/lib/tftpboot/pxelinux/pxelinux.cfg/default Add... To the corresponding location of the configuration file inst.ks=http://192.168.122.174/kickstart/cclinux-2203-x86_64.cfg Options .)
  1. stay /var/lib/tftpboot/ Create subdirectories in , And copy the boot image file . for example :
$ sudo mkdir -p /var/lib/tftpboot/pxelinux/images/cclinux-2203-rc1-x86_64/
$ pwd
/var/www/html/CCLinux-2203-x86_64-rc1
$ sudo cp images/pxeboot/{
    vmlinuz,initrd.img} /var/lib/tftpboot/pxelinux/images/cclinux-2203-rc1-x86_64/
  1. stay DHCP Server , Turn on the enable DHCP service .
$ sudo systemctl start dhcpd
$ sudo systemctl enable dhcpd
Created symlink /etc/systemd/system/multi-user.target.wants/dhcpd.service → /usr/lib/systemd/system/dhcpd.service.
  1. Turn on the enable tftp service
$ sudo systemctl start tftp.service
$ sudo systemctl enable tftp.service

And look at tftp Service port

$ netstat -a | grep tftp
udp6       0      0 [::]:tftp               [::]:*

PXE The boot server is now configured , You can use it. PXE Mode to start the client .

if PXE The server is a virtual machine environment , Then it can be tested on the group host pxe install , as follows :

#!/bin/bash
OS_NAME=os-1
sudo virt-install \
		--virt-type=kvm \
		--name $OS_NAME\
		--memory 8192 \
		--vcpus 8 \
		--os-type=linux \
		--os-variant=centos-stream9 \
		--pxe \
		--network=default,model=virtio \
		--disk path=/var/lib/libvirt/images/$VM_NAME.qcow2,size=10,format=qcow2 \
		--check all=off

Manual configuration is still required during installation anaconda technological process , This needs to be kickstart, The following text will be on kickstart sketch .

Be careful :

  1. Firewalls cause PXE Download success and failure .
  2. PXE The process can be tested by capturing packets tcpdump -i enp0s8 port 67 or port 68 or port 69 or port 80 -n -e -vv.

2. Based on UEFI Client configuration PXE The server

important

  • All configuration files in this chapter are examples . Configuration details depend on your architecture and requirements ;
  • Red hat UEFI PXE Startup support is based on lowercase MAC Address format grub Menu file , for example ,grub.cfg-01-aa-bb-cc-dd-ee-ff

step

  1. root user , install tftp and dhcp service ( And BIOS Same chapter )
  2. Allow access to tftp( And BIOS Same chapter )
  3. To configure DHCP The server ,( And BIOS Same chapter )
  4. mount ISO Mirror image , obtain rpm package shim and grub2-efi;
  5. from shim Extract in package BOOTX64.efi file , from grub2-efi Extract from grubx64.efi file (BOOTX64.EFI Pay attention to case ):
$ rpm2cpio shim-x64-15-15.el8_2.x86_64.rpm | cpio -div
$ rpm2cpio grub2-efi-x64-2.06-13.el9.x86_64.rpm | cpio -div

So I got BOOTX64.EFI( Pay attention to case ) and grubx64.efi file .

  1. Create folder mkdir /var/lib/tftpboot/uefi And copy the files
$ pwd
/home/rongtao/grub2-efi/boot/efi/EFI/centos
$ sudo cp grubx64.efi /var/lib/tftpboot/uefi
  1. stay /var/lib/tftpboot/ Add a configuration file to the directory grub.cfg, The contents are as follows :
set timeout=60
menuentry 'CCLinux 2203 rc1' {
    
	linuxefi images/cclinux-2203-rc1-x86_64/vmlinuz ip=dhcp inst.repo=http://192.168.122.22/CCLinux-2203-x86_64-rc1/
	initrdefi images/cclinux-2203-rc1-x86_64/initrd.img
}

Refer to the above BIOS Files created during configuration /var/lib/tftpboot/pxelinux/pxelinux.cfg/default.

Be careful : Reference resources BIOS Precautions during configuration ( About repo,.treeinfo,BaseOS,AppStream

  1. stay /var/lib/tftpboot/ Create subdirectories in , And copy the boot image file .( And BIOS Same chapter )
  2. Start and enable dhcp;( And BIOS Same chapter )
  3. Start and enable tftp;( And BIOS Same chapter )

TODO: Because I was tested in a virtual machine environment , my virt-install edition 2.2.1 I won't support it uefi, So there was no test .

3. by IBM Power System configuration network server

A little .

Problems that may be encountered during the installation process

1. No DEFAULT or UI configuration directive found!

Note in the configuration file /var/lib/tftpboot/pxelinux/pxelinux.cfg/default designated default vesamenu.c32 stay /var/lib/tftpboot/pxelinux/vesamenu.c32 Whether there is .

2. DHCP: via enp1s0: unknown lease 192.168.122.34.

2. PXE: No more network device

2. PXE: Nothing to boot: No such file or directory

see systemctl status dhcpd Show

2 month  11 15:08:14 localhost.localdomain dhcpd[1920]: DHCPDISCOVER from 52:54:00:ee:17:09 via enp1s0
2 month  11 15:08:15 localhost.localdomain dhcpd[1920]: DHCPOFFER on 192.168.122.191 to 52:54:00:ee:17:09 via enp1s0
2 month  11 15:08:22 localhost.localdomain dhcpd[1920]: DHCPREQUEST for 192.168.122.34 (192.168.122.1) from 52:54:00:ee:17:09 via enp1s0: unknown lease 192.168.122.34.

Reference link

Check

Firewall – Check ufw has rules setup for Port 69
tftpd – Check daemon listening on Port 69
dhcpd – Check Running and no lease issues.
No File – Check the pxelinux.0 file is actually on the server!

TFTP command

Use tftp Command download tftp Files on the service .

see

[[email protected] ~]$ arp -a| grep 192
? (192.168.122.191) at <incomplete> on enp1s0
? (192.168.122.190) at <incomplete> on enp1s0
? (192.168.122.110) at <incomplete> on enp1s0
? (192.168.122.109) at 52:54:00:0e:41:1e [ether] on enp1s0
? (192.168.122.42) at <incomplete> on enp1s0
? (192.168.122.34) at <incomplete> on enp1s0
_gateway (192.168.122.1) at 52:54:00:28:f6:80 [ether] on enp1s0

Use command arp -d 192.168.122.191 Delete <incomplete>IP Address .

=====================================================================================================

build PXE Remote installation server -OLD-Fatal

1. Install and enable TFTP service

1.1. install TFTP service

$ sudo dnf -y install tftp-server xinetd

1.2. modify TFTP Service configuration file and start

vim /etc/xinetd.d/tftp
	protocol                = udp		#TFTP By default UDP agreement 	
    wait                    = no		#no Indicates that multiple clients can be connected together ,yes Indicates that the client can only be connected to one by one 
    server_args             = -s /var/lib/tftpboot		# Appoint TFTP root directory ( The storage path of the boot file )
    disable                 = no		#no Open for indication TFTP service 
# default: off
# Description: The tftp server serves files using the trivial file transfer
# 	protocol, Thsi tftp protocol is oftern used to boot diskless 
# 	workstations, download configuration file to network-aware printers,
# 	and to start the installation process for some  operation systemds.
# 	https://blog.csdn.net/ItookapillinNJ/article/details/114122524

service tftp
{
	socket_type	= dgram
	protocol	= udp
	wait		= no
	user		= root
	server		= /usr/sbin/in.tftpd
	server_args	= -s /var/lib/tftpboot
	disable		= no
	per_source	= 11
	cps		= 100 2
	flags		= IPv4
}

Opening service

systemctl start tftp
systemctl start xinetd

2. install DHCP service

$ sudo dnf install dhcp-server

To configure :

#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp-server/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#
ddns-update-style interim;
ignore client-updates;
filename "grubaa64.efi";
next-server 192.168.122.22;
subnet 192.168.122.0 netmask 255.255.255.0 {
  range dynamic-bootp  192.168.122.213 192.168.122.215;
  default-lease-time 600;
  max-lease-time 7200;                                                                                                      
}

3. Get ready Linux kernel 、 Initialize image file

$ sudo cp vmlinuz /var/lib/tftpboot/
$ sudo cp initrd.img /var/lib/tftpboot/

4. Get ready PXE Bootstrap

$ sudo dnf install syslinux
$ sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

5. install FTP service , Get ready CentOS 7 Install source

I use first httpd try .

6. Configure the Startup menu file

$ sudo mkdir /var/lib/tftpboot/pxelinux.cfg

7. Turn off firewall , verification PXE network install

8. verification pxe install

Reference resources PERFORMING AN ADVANCED RHEL INSTALLATION

Reference link


Copyright (C) CESTC Com.
原网站

版权声明
本文为[rtoax]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131017376129.html