PXE batch network installation and KickStart unattended installation (super detailed experimental tutorial)

Table of contents

1. PXE

2. Requirements for building a PXE network system

3. Steps to build a PXE remote installation server

4. PXE specific deployment experiment

1. Install and enable TFTP service

Five, unattended installation of linux system 

 Experimental verification

1. PXE

  PXE (pre-boot execution environment, running before the operating system) is a network boot technology developed by Intel Corporation, working 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 . A preboot execution environment, which runs before the operating system. 

  • dhcp implements automatic address assignment
  • ftp transfers the installation files to the client
  • xinetd A new generation of network daemon service program that manages lightweight Internet services
  • tftp simple file transfer protocol udp protocol, simple file transfer (small files) between server and client, depends on xinetd management, port number 69

1.1 Advantages of pxe batch deployment

Scale: Simultaneously assemble multiple servers

Automation: install the system, configure various services

Remote implementation: no CD, U disk and other installation media are required

PXE (Preboot eXcution Environment)
pre-boot execution environment, running before the operating system
Server
Running DHCP service, used to assign addresses and locate boot programs
Run TFTP service, provide boot program download
Client
Network card supports PXE protocol
Motherboard supports network boot

1.2 Basic deployment process

Prepare CentOS 7 installation source (YUM repository)
Install and enable TFTP service
Provide Linux kernel, PXE boot program, etc.
Install and enable DHCP service
Configure boot menu
 

2. Requirements for building a PXE network system

  • Server : Run DHCP service to assign addresses and locate bootloader; run TFTP service to provide bootloader download. There is a DHCP server in the network to automatically assign addresses to clients and specify the location of bootloader files. The server should provide the download of the boot image file through the TFTP service (Trivial File Transfer Protocol).
  • Client : The network card supports the PXE protocol; the motherboard supports network boot, the network card of the client must support the PXE protocol (integrated BOOTROM chip), and the motherboard supports network boot. For some, you need to allow booting from Network or LAN in the BIOS settings.

3. Steps to build a PXE remote installation server

The PXE remote installation server integrates CentOS 7 installation sources, TFTP services, DHCP services, and FTP services, and can send data such as PXE boot programs, Linux kernels, and boot menus to client bare metal, as well as provide installation files.

TFTP (Trivial File Transfer Protocol) is a protocol based on UDP protocol for simple file transfer between client and server, suitable for small file transfer applications. TFTP service is managed by xinetd service by default, using UDP port 69.
xinetd is a new generation of network daemon service program, also called super server, which is often used to manage various lightweight Internet services.
 

4. PXE specific deployment experiment

1. Install and enable TFTP service

[root@localhost ~]# yum -y install tftp-server xinetd //yum installs tftp and xinetd services

 #Modify the configuration file of the TFTP service
vim /etc/xinetd.d/tftp
protocol = udp #TFTP uses the UDP protocol by default
wait = no #no means that multiple clients can connect together, yes means that the client can only connect one by one
server_args = -s /var/lib/tftpboot #Specify the TFTP root directory (the storage path of the boot file)
disable = no #no means to enable the TFTP service

//配置完成后开启并设置自启动服务
[root@localhost xinetd.d]# systemctl start tftp
[root@localhost xinetd.d]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@localhost xinetd.d]# systemctl start xinetd
[root@localhost xinetd.d]# systemctl enable xinetd

2. Install and enable DHCP service 

[root@localhost xinetd.d]# yum -y install dhcp

[root@localhost xinetd.d]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? yes

 Modify the configuration file of the DHCP service
vim /etc/dhcp/dhcpd.conf
ddns-update-style none; #Disable DNS dynamic update to improve operating efficiency
next-server 192.168.80.10; #Specify the address of the TFTP server, that is, your own virtual machine Address (manual input)
filename "pxelinux.0"; #Specify the file of the PXE boot program to be downloaded (this is manual input)

subnet 192.168.50.0 netmask 255.255.255.0 { #Declare the address of the network segment to be allocated

range 192.168.50.100 192.168.50.200; #Set address pool

option routers 192.168.50.22; #The default gateway address points to the IP address of the TFTP server}

//启动服务
[root@localhost xinetd.d]# systemctl start dhcpd
[root@localhost xinetd.d]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
[root@localhost xinetd.d]# 

3. Prepare the Linux kernel and initialize the image file

[root@localhost xinetd.d]# mount /dev/cdrom /mnt #先挂载光盘镜像
[root@localhost xinetd.d]# cd /mnt/images/pxeboot/
[root@localhost pxeboot]# ls
initrd.img  TRANS.TBL  vmlinuz
[root@localhost pxeboot]# cp vmlinuz /var/lib/tftpboot/ #复制 Linux系统的内核文件到TFTP根目录
[root@localhost pxeboot]# cp initrd.img /var/lib/tftpboot/ #复制 初始化镜像文件(linux引导加载模块)到TFTP根目录下

4. Prepare PXE bootloader

[root@localhost pxeboot]# yum -y install syslinux #PXE bootloader
[root@localhost pxeboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ #copy PXE bootloader to TFTP root directory Down

 5. Install FTP service and prepare CentOS7 installation source

[root@localhost tftpboot]# yum -y install vsftpd #Install vsftpd service
[root@localhost tftpboot]# mkdir /var/ftp/centos7 #Create new centos7 directory
[root@localhost tftpboot]# cp -rf /mnt/* /var /ftp/centos7/ #Copy all the files under the CD image to the centos7 directory

6. Configure the boot menu file

#The default boot menu file is in the pxelinux.cfg subdirectory of the TFTP root directory, and the file name is default

[root@localhost centos7]# mkdir /var/lib/tftpboot/pxelinux.cfg #need to create pxelinux.cfg in the ftfpboot directory
[root@localhost centos7]# vim /var/lib/tftpboot/pxelinux.cfg/default #in Create default in the pxelinux.cfg directory and edit the configuration file

7. Turn off the firewall and verify the PXE network installation 

[root@localhost centos7]# systemctl stop firewalld
[root@localhost centos7]# setenforce 0

Five, unattended installation of linux system 

1.yum install system-config-kickstart tool

[root@localhost centos7]# yum -y install system-config-kickstart

 2. Execute the "system-config-kickstart" command to open the "Kickstart Configuration Program" window

2.1 Basic configuration

 2.2 Installation method

 2.3 Bootloader Options

2.4 Partition information

 

 

2.5 Network configuration

 2.6 Firewall configuration

 2.7 Post-installation scripts

2.8 save configuration

 2.9 Configure the software packages that need to be installed

 可以根据需要将/root/anaconda-ks.cfg 的软件包安装脚本复制到/var/ftp/ks.cfg文件中,只需要复制%packages 到%end 部分即可。如要求最小化安装,可复制下面内容:vim ks.cfg
%packages
@^minimal
%end

[root@localhost ~]# cp ks.cfg /var/ftp/ks.cfg
[root@localhost ~]# cd /var//ftp/
[root@localhost ftp]# ls
centos7  ks.cfg  pub
[root@localhost ftp]# vim ks.cfg 

 [root@localhost ftp]# vim /var/lib/tftpboot/pxelinux.cfg/default

 Experimental verification

 Create a new virtual machine

 

 Start the virtual machine when done.

Guess you like

Origin blog.csdn.net/weixin_42054864/article/details/131589326