1. PXE Overview
1. The role of PXE
A pre-boot execution environment, which runs before the operating system.
2. Advantages of PXE batch deployment
(1) Scale: assemble multiple servers at the same time;
(2) Automation: install the system and configure various services;
(3) Remote implementation: no CD, U disk and other installation media are required.
3. Server
(1) Run the DHCP service to assign addresses and locate the bootloader
(2) Run TFTP service, provide bootloader download (TFTP: similar to vsftp small text transfer protocol, provide image file download)
4. Client
(1) The network card supports the PXE protocol
(2) The motherboard supports network boot
2. Configure PXE installation server
1. Basic deployment process
(1) The client searches for the dhcp service through the network card, and obtains the IP address and time
(2) The DHCP server assigns the IP address and the address of the boot program to the client, and at the same time sends the address of the tftp server to the client through the offer message
(3) The tftp server sends the boot file (pxelinux.0) to the client
(4) The client loads the bootloader into memory
(5) The bootloader searches for the configuration file in the tftp server, and the server sends the configuration file to the client (the configuration file is obtained by ftp)
(6) The server obtains the mirror file of the system by transferring files between the server and the client through the vsftp service
2. Four major files required for PXE installation
2.1PXELINUX.0
bootloader (provided by the syslinux program)
syslinux: a boot loader that simplifies the time to install Linux for the first time, and create boot disks for maintenance or other special users
2.2default
The configuration file of the bootloader (features: need to be handwritten, the template is in the CD file: isolinux.cfg in the isolinux directory)
2.3vmlinuz
Kernel file (from the CD, in the isolinux directory)
2.4initrd.img
System boot image file (from CD, in isolinux)
3. Services required by PXE
(1) dhcp
(2) tftp: port number – 69, based on UDP protocol, simple file transfer, transfer some small files
(3) vsftpd
(4) xinetd: installed together with tftp, the network daemon service program, used to manage lightweight network services, used with tftp
Three. PXE configuration
1. Use local source installation service
cd /etc/yum.repos.d/ mount /dev/cdrom /mnt/ vim local.repo
yum clean all & amp; & amp; yum makecache
2. Install and start TFTP service
yum -y install tftp-server xinetd
vim /etc/xinetd.d/tftp
systemctl start tftp #Service starts automatically systemctl start xinetd #Open xinetd service systemctl enable xinetd #Enable xinetd service to boot automatically systemctl stop firewalld.service #Close the system firewall setenforce 0 #Turn off the system security mechanism
3. Install and start DHCP service
yum -y install dhcp #Install the dhcp package cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf #Copy the dhcp configuration template to the dhcp configuration file vim /etc/dhcp/dhcpd.conf #Modify the configuration file of the DHCP service
systemctl start dhcpd systemctl enable dhcpd
4. Prepare the Linux kernel and initialize the image file
mount /dev/sr0 /mnt #mount cd /mnt/images/pxeboot cp vmlinuz /var/lib/tftpboot/ #Copy the kernel file of the Linux system to the TFTP root directory cp initrd.img /var/lib/tftpboot/ #Copy the initialization image file (linux bootloader module) to the TFTP root directory
5. Prepare PXE bootloader
yum -y install syslinux #PXE bootloader is provided by the package syslinux cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ #Copy the PXE bootloader to the TFTP root directory
6. Install vsftpd service, prepare CentOS 7 installation source
yum -y install vsftpd --------install vsftpd service mkdir /var/ftp/centos7 --------Create directory centos7 under the ftp root directory cp -rf /mnt/* /var/ftp/centos7/ ---Forcibly copy the image file to the centos7 directory, you can add & amp; to let it run in the background systemctl start vsftpd----------- Open vsftpd service systemctl enable vsftpd-------------Enable vsftpd service to start automatically
7. 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
mkdir /var/lib/tftpboot/pxelinux.cfg--------Create directory vim /var/lib/tftpboot/pxelinux.cfg/default
After the configuration is complete, you can check whether the relevant files exist at the following address
cd /var/lib/tftpboot/
Check if it is centos7 at the following address
cd /var/ftp
8. Install a new virtual machine
During the installation process, you need to pay attention to the following pages, and the rest can be defaulted:
9. Realize Kickstart unattended installation configuration
9.1 Install system-config-kickstart tool
yum install -y system-config-kickstart
9.2 Implement the Kickstart configuration program in the virtual machine of test1
Open it through the desktop menu “Applications” –> “System Tools” –> “Kickstart” or execute the “system-config-kickstart” command to open it. The following needs to be modified, and the rest can be defaulted
Partition information:
Master Boot Record: Clear the Master Boot Record
Partition: delete all existing partitions
disklabel: initialize disklabel
Layout: Adding Partitions
Mount point: /boot, file system type: xfs, fixed size: 500M
File system type: swap, fixed size: 4096M
Mount point: /home, file system type: xfs, fixed size: 4096M
Mount point: /, file system type: xfs, use all unused space on the disk
9.3 Save the automatic answer file and copy it to the directory to be implemented
Select the “File” -> “Save” command in the “Kickstart Configurator” window, choose to specify the save location, and the file name is ks.cfg
Saved in /root/ks.cfg by default
9.4 Configure the software packages that need to be installed
You can copy the package installation script of vim anaconda-ks.cfg to the vim ks.cfg file as needed,
Just copy %packages to %end section.
If you require a minimal installation, you can copy the following:
vim ks.cfg
%packages
@^minimal
%end
vim ks.cfg
cp /root/ks.cfg /var/ftp/ks.cfg #Copy the file ks.cfg to /var/ftp/ks.cfg
9.5 Edit boot menu file default, add ks boot parameters
vim /var/lib/tftpboot/pxelinux.cfg/default
9.6 Verify unattended installation
When the client computer boots in PXE mode each time, it will automatically download the ks.cfg response configuration file, and then install the CentOS 7 system according to the settings in it, including setting the root user password without manual intervention.
cat /etc/yum.repos.d/local.repo