PXE efficient batch network installation

catalogue

1, How to deploy PXE remote installation service

1. PXE principle

2. PXE concept

3. PXE benefits

4. Prerequisites for deploying PXE

5. KickStart overview

6. Construction process of PEX service

7,TFTP

8,xinetd

9. vmlinuz (bootable, compressed kernel)

10. initrd (system initialization file)

11. pxelinux.0 (Startup menu file)

2, Steps for setting up PXE remote installation server

1. Required installation package

2. Installation steps

3, Implement Kickstart unattended installation

1. Required installation package

2. Installation steps

  summary

In the large-scale Linux application environment, when the number reaches more than ten or hundreds of server bare machines to realize rapid system installation, PXE can be used to efficiently install the network in batches, and Kickstart can also be used for unattended installation, which greatly reduces the burden of administrators. Here is a brief introduction to PXE and Kickstar configuration.

1, How to deploy PXE remote installation service

1. PXE principle

PXE is a network boot technology developed by Intel. It works in the Client/Server mode, allowing the client to download the boot image from the remote server through the network and load the installation file or the entire operating system.

2. PXE concept

PXE is not strictly an installation method, but a boot method. The necessary condition for PXE installation is that the computer to be installed contains a PXE supported network card (NIC), that is, there must be a PXE Client in the network card. PXE (pre boot execution environment) protocol enables the computer to boot through the network.

The protocol is divided into Client and Server. The PXE Client is in the ROM of the network card. When the computer boots, the BIOS calls the PXE Client into the memory for execution, and the PXE Client downloads the files placed at the remote end to the local operation through the network.

DHCP server and TFTP server need to be set up to run PXE protocol. The DHCP server is used to assign an IP address to the PXE Client (the host on which the system will be installed). Since the IP address is assigned to the PXE Client, the corresponding PXE settings need to be added when configuring the DHCP server.

In addition, TFTP Client already exists in the ROM of PXE Client. PXE Client downloads required files from TFTP Server through TFTP protocol.

3. PXE benefits

(1) Large scale: assemble multiple servers at the same time;

(2) Automation: install system and configure various services;

(3) Remote implementation: no installation media such as optical disk and U SB flash disk are required.

4. Prerequisites for deploying PXE

(1) The network card of the client supports PXE protocol (integrated BOOTROM chip), and the motherboard supports network boot.

(2) There is a DHCP server in the server to automatically assign the address and specify the boot file location for the client. The server provides the download of boot image files through TFTP (simple file transfer protocol).

(3) The first condition is actually the hardware requirement. At present, most servers and most PC s can provide this support. You only need to allow starting from Network or LAN in BTOS settings.

5. KickStart overview

(1) KickStart is an unattended installation.

(2) The working principle of KickStart is to record various parameters filled in by manual intervention during typical installation, and generate a file named ks.cfg.

(3) In the subsequent installation process (not limited to the machines that generate KickStart installation files), when parameters are required to be filled in, the installer will first find the files generated by KickStart. When appropriate parameters are found, the found parameters will be used. When appropriate parameters are not found, the installer needs manual intervention.

(4) If the KickStart file covers all the parameters that need to be filled in during the installation process, the installer can only tell the installer where to get the ks.cfg file, and then do his own business. After installation, the installer will restart the system according to the restart option set in ks.cfg and end the installation.

6. Construction process of PEX service

(1) The PXE client sends a request for an IP address to the DHCP server.

(2) The DHCP server will respond to the request of the PXE client, automatically allocate an IP address from the IP address pool to the PXE client, and inform the PXE client that the IP address of the TFTP server and the PXE boot program file "pxelinux.0" are under the TFTP shared directory / var/lib/tftpboot / by default

(3) The PXE client initiates a request to the TFTP server to obtain the "pxelinux.0" bootstrap file.

(4) The TFTP server responds to the PXE client's request and transfers its shared "pxelinux.0" file to the PXE client.

(5) The PXE client starts to the system installation main interface through the network.

(6) The PXE client sends a request to the file sharing server (ftp, http, nfs, etc.) to obtain Centos or Windows system installation files.

(7) The file sharing service responds to the PXE client's request and transfers the shared system installation files to the PXE client.

(8) The PXE client enters the installation prompt wizard interface, and the user needs to manually complete the system installation.

7,TFTP

(1) TFTP (full name: triple file transfer protocol) is a small and easy to implement file transfer protocol.

(2) TFTP is based on UDP datagrams and needs its own error correction measures.

(3) TFTP only supports file transfer, does not support interaction, and does not have a large command set. There is no directory list function, and users cannot be authenticated. However, its code occupies less memory and can solidify TFTP code without hard disk. It is very suitable for small computers and special-purpose devices.

(4) A major difference between TFTP and FTP is that it is not interactive and does not authenticate.

(5) TFTP is generally used to transfer small files

8,xinetd

xinetd (full name: extended internet daemon), used to host tftp, is a new generation of network daemon service program, also known as super Internet server. It is often used to manage a variety of lightweight Internet services. xinetd provides services similar to inetd+tcp_wrapper's function, but more powerful and secure.

9. vmlinuz (bootable, compressed kernel)

Where "vm" stands for "Virtual Memory". Linux supports Virtual Memory, unlike the old operating system, such as DOS, which has a memory limit of 640KB. Linux can use hard disk space as Virtual Memory, so it is named "vm". Vmlinuz is an executable Linux kernel. It is located in / boot/vmlinuz. It is generally a soft link.

10. initrd (system initialization file)

initrd is short for "initial ramdisk". initrd is generally used to temporarily boot the hardware to a state where the actual kernel vmlinuz can take over and continue to boot. initrd.img is mainly used to load file systems such as ext4 and scsi devices.

11. pxelinux.0 (Startup menu file)

(1) The Startup menu is used to guide the boot process of the client, including how to call the kernel and how to load the driver.

(2) The default Startup menu file is default and should be placed in the pxelinux.cfg subdirectory of the tftp root directory. For typical Startup menu configuration, refer to the following operations to establish it automatically or manually.

(3) / var/lib/tftpboot/pxelinux.cfg/default file, because it is determined by pxelinux.0 file.

2, Steps for setting up PXE remote installation server

1. Required installation package

(1)dhcp.x86_64 12:4.2.5-7pd-3.0.2-27.el7.x86_64.r9.el7.centos: used to assign ip addresses to clients

(2)syslinux-4.05-15.el7.x86_64.rpm: boot program used to provide pxe

(3)tftp-server.x86_64 0:5.2-22.el7.rpm: used to download boot image files

(4)xinetd.x86_64 2:2.3.15-14.el7: used to host tftp

2. Installation steps

(1) Install and enable DHCP service

[root@localhost ~]# yum install dhcp -y     #(install dhcp package)
[root@localhost ~]# cp -rfp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf     #(copy)
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf     #(profile)
ddns-update-style none;     #(disable dynamic updates)
subnet 192.168.100.0 netmask 255.255.255.0 {     #(configure network segment)
  range 192.168.100.150 192.168.100.200;     #(configure address pool)
  option routers 192.168.100.100;     #(configure gateway)
  next-server 192.168.100.100;     #(specify the address of the tftp server)
  filename "pxelinux.0";     #(specify the file name of the pxe bootstrapper)
}
[root@localhost ~]# systemctl start dhcpd     #(start dchp service)
[root@localhost ~]# systemctl enable dhcpd     #(dhcp service starts automatically after startup)

(2) Install and enable TFTP service

[root@localhost ~]# yum install tftp-server -y     #(install TFTP server and xinetd packages)
[root@localhost ~]# mount /dev/sr0 /mnt/     #(CD mount)
[root@localhost ~]# vim /etc/xinetd.d/tftp      #(profile)
disable                 = no      #(start TFTP service)
[root@localhost ~]# cd /mnt/images/pxeboot/     #(enter pxeboot directory)
[root@localhost pxeboot]# ls     #(view the files in pxeboot directory)
initrd.img  TRANS.TBL  vmlinuz
[root@localhost pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/     #(copy the two files to the tftpboot directory)
[root@localhost pxeboot]# ls /var/lib/tftpboot/     #(view the files in the tftpboot directory)
initrd.img  vmlinuz
[root@localhost ~]# systemctl start tftp     #(start tftp service)
[root@localhost ~]# systemctl status tftp     #(view tftp service status)
[root@localhost ~]# systemctl enable tftp     #(start the tftp service after startup)

(3) Prepare PXE bootstrap pxelinux.0

[root@localhost ~]# yum install syslinux -y     #(install package for syslinux)
[root@localhost ~]# rpm -ql syslinux | grep pxelinux.0     #(view the location of the pxe bootstrapper)
/usr/share/syslinux/pxelinux.0
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/     #(copy the file system boot file to the tftpboot directory)
[root@localhost ~]# cd /var/lib/tftpboot/     #(to tftpboot directory)
[root@localhost tftpboot]# mkdir pxelinux.cfg     #(create a pxelinux.cfg directory)
[root@localhost tftpboot]# ls     #(view the directory where pxelinux.cfg was created)
initrd.img  pxelinux.0  pxelinux.cfg  vmlinuz
[root@localhost tftpboot]# vim pxelinux.cfg/default     #(configure Startup menu file)
default auto     #(specify the default entry name, corresponding to the following label auto)
prompt 0     #(set whether to wait for user selection. 1 means to wait for user control, 0 means not to wait for user control. boot will appear during installation: press enter to select auto mode)
 
label auto     #(default graphic installation)
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg      #(specify network path)

label linux text     #(text installation mode, enter linux text when boot: appears)
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg      #(specify network path)

label linux rescue     #(in rescue mode, enter linux rescue when boot: appears)
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg      #(specify network path)

(4) Install ftp service and prepare CentOS7 installation source

[root@localhost ~]# yum install vsftpd -y     #(install the package of vsftpd)
[root@localhost ~]# mkdir /var/ftp/centos7     #(create centos7 directory)
[root@localhost ~]# cp -rf /mnt/* /var/ftp/centos7/ &     #(copy all files in mnt directory to centos7 directory)
[root@localhost ~]# systemctl start vsftpd     #(start vsftpd service)
[root@localhost ~]# systemctl status vsftpd     #(view vsftpd service status)
[root@localhost ~]# systemctl enable vsftpd     #(start vsftpd service after startup)

3, Implement Kickstart unattended installation

1. Required installation package

(1) system-config-kickstart.noarch 0:2.9.7-1.el7.rpm: used for unattended installation

2. Installation steps

(1) Prepare to install answer file

After installing the system config kickstart tool in CentOS 7 system, you can configure the installation response file through the graphical Wizard tool. If you are familiar with the configuration of the auto answer file, you can also directly edit the answer file automatically created after CentOS 7 installation (/ root / Anaconda KS. CFG) and use it after appropriate revision as needed.

[root@localhost ~]# yum install system-config-kickstart.noarch -y

(2) Configuration under Kickstart Configurator

 ( 3) Configuration ks.cfg file

[root@localhost ~]# cd /var/ftp/     #(to ftp directory)
[root@localhost ftp]# ls     #(view the ks.cfg file)
centos7  ks.cfg  pub
[root@localhost ftp]# vim ks.cfg     #(edit ks.cfg file)
# SELinux configuration
selinux --disabled
part / --fstype="xfs" --grow --size=1

%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install     #(new installation)
# Keyboard layouts
keyboard 'us'     #(English keyboard)
# Root password
rootpw --iscrypted $1$QeQPBKWP$GJCl.NA7aYxOarXGweqXy.     #(root password)
# Use network installation
url --url="ftp://192.168.100.100/centos7 "# (network installation path)
# System language
lang zh_CN     #(system language, zh)_ Cn stands for Chinese)
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical     #(character mode installation, graphical means graphical installation)
firstboot --disable
# SELinux configuration
selinux --disabled     #(disable selinux)

# Firewall configuration
firewall --disabled     #(disable firewall)
# Network information
network  --bootproto=dhcp --device=ens33     #(network card configuration)
# Reboot after installation
reboot     #(restart after installation)
# System timezone
timezone Asia/Shanghai     #(time zone: Shanghai)
# System bootloader configuration
bootloader --location=mbr     #(mbr boot)
# Partition clearing information
clearpart --all     #(clear all partition information and initialize partition labels)
# Disk partitioning information
part /boot --fstype="xfs" --size=500     #(partition configuration)
part swap --fstype="swap" --size=4096     #(partition configuration)
part / --fstype="xfs" --grow --size=1     #(partition configuration)

%packages
@^gnome-desktop-environment     #(install desktop environment)
@base     #(install basic package)
@core
@desktop-debugging
@development
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
kexec-tools

%end

  summary

1. To realize PXE remote installation, the network card must support PXE function, and must have Linux Installation source and available TFTP and DHCP servers.

2. The unattended response file can be completed through the Kickstar configuration program, which is provided by the system config kickstart software package.

Tags: Linux

Posted on Wed, 01 Sep 2021 20:28:25 -0400 by mfalomir