when installing servers on a large scale, a batch automation method is required to install the server to reduce the daily workload.
However, the base of the batch Automation installation server is the network boot server (bootserver).
Below we introduce the network boot server installation and configuration method, for everyone to practice!
1. Terminology used in this article to explain
Pxe
PXE (Pre-Boot execution Environment) is an Intel-designed protocol that enables a computer to boot over a network rather than from a local hard disk, optical drive, and so on. Modern NICs, typically embedded with PXE-enabled ROM chips. When the computer boots, the BIOS puts the PXE client into memory execution, and displays the Command menu, after the user chooses, the PXE client will be placed on the remote operating system to be downloaded to the local operation on the network.
Dhcp
DHCP (Dynamic Host control Protocol) dynamically hosts the controlling protocol. Used to assign IP addresses to clients centrally and dynamically.
Tftp
TFTP (Trivial File Transfer Protocol), a very small file transfer Protocol, is syntactically similar to FTP. Because it is simple and efficient, it is often used for OS and configuration updates of network devices.
2. PXE principle
2.1. PXE Client Api (Schema)
Figure PXE API architecture diagram. (Image source: PXE Specification Version 2.1)
Description: When the BIOS loads the PXE client into memory, it has the ability to DHCP client and TFTP client.
The PXE client has the DHCP client capability to obtain IP addresses through the DHCP server.
The PXE client has TFTP client capability "and can be used to download files such as kernel image via TFTP.
2.2. PXE boot flowchart (PXE boot)
The
startup process is described as follows:
The PXE Client broadcasts dhcpddiscover messages to UDP 67 ports.
After a DHCP SERVER or DHCP Proxy receives a broadcast message, it sends a dhcpoffer (containing an IP address) message to the PXE client's 68 port. The
PXE Client sends a DHCPREQUEST message to the DHCP SERVER to obtain the boot file name. The
DHCP SERVER sends a DHCPACK (containing the network Bootstrap program file name) message to the PXE Client. The
PXE Client obtains an NBP (Network Bootstrap program) file to Boot Server.
The PXE client downloads the NBP from the TFTP server, and then executes the NBP file on the client
Note: After the NBP is initialized, the NBP downloads the other required configuration files from the TFTP server in its own default manner.
This time the PXE boot process is complete and the rest of the work is done with an NBP.
For example: pxelinux.0 (NBP) He downloads the default configuration file to display the menu, starting a different kernel image as needed.
If the NBP is a RIS (window installation), Windows boot loader is started to perform the installation Deployment Widows task.
3. PXE BOOT Server configuration process
The following configurations and tests are all done on Centos5, and other systems are at your discretion!
3.1. DHCP installation and configuration
during PXE boot, the PXE client obtains the IP address, the NBP file name through DHCP server, and then downloads the NBP file from the TFTP server and executes it on the client. To start the computer.
Verify that the DHCP package is installed in the System
Edit the/etc/dhcpd.conf configuration file with the contents of the configuration file as follows
[[Email protected]]# cat/etc/dhcpd.conf
Ddns-update-style Interim;
Allow booting; #定义能够PXE启动
Allow BOOTP; #定义支持bootp
Next-server 192.168.0.1; IP address of the #TFTP server
FileName "pxelinux.0"; #bootstrap file (NBP)
Default-lease-time 1800;
Max-lease-time 7200;
Ping-check true;
Option Domain-name-servers 192.168.0.1;
Subnet 192.168.0.0 netmask 255.255.255.0
{
Range 192.168.0.128 192.168.0.220;
Option routers 192.168.0.1;
Option broadcast-address 192.168.0.255;
}
NOTE: the filename "pxelinux.0" is in the/etc/dhcpd.conf configuration file, and the file directory is the root directory relative to the TFTP (default is/tftpboot).
So the absolute path to the file is:/tftpboot/pxelinux.0 "; Of course it can be specified as a different path.
After the configuration is complete, restart the DHCP service and set it to boot from
[[Email protected]]#/etc/init.d/dhcpd Start
Start dhcpd: [OK]
[Email protected]]# chkconfig--level dhcpd on
3.2. Install the configuration TFTP server
during the PXE boot process, the PXE Client uses the TFTP protocol to download the bootstrap file from the TFTP server and executes it.
Verify that the Tftp-server package is installed in the system
Configure the TFTP service, the TFTP service is managed by the XINETD service
Edit the/etc/xinetd.d/tftp file, change disable = Yes to: Disable = no The contents of the configuration file are as follows:
[[email protected]]# cat/etc/xinetd.d/tftp
# default:off
# description:the TFTP Server serves files using the trivial file transfer \
# protocol. The TFTP protocol is often used to boot diskless \
# workstations, download configuration files to Network-aware Printe RS, \
# and to start the installation process for some operating systems.
# Default:off
# description:the TFTP server serves files using the trivial file transfer \
# protocol. The TFTP protocol is often used to boot diskless \
# workstations, download configuration files to Network-aware Printe RS, \
# and to start the installation process for some operating systems.
Service tftp
{
Socket_type = dgram
protocol = UDP
wait = yes
user = root
Server =/USR/SBIN/IN.TFTPD
server_args =-s/tftpboot
Disable = no
Per_source = one
CPS = 2
Flags = IPV4
}
Note: The root directory of the TFTP server is/tftpboot, and the XINETD service is restarted after the configuration is complete, allowing the TFTP server to take effect.
[Email protected]]#/etc/init.d/xinetd Restart
Bootstrap file configuration (NBP), used here pxelinux.0
The bootstrap file is provided by the Syslinux package, and as soon as we install the syslinux, the pxelinux.0 file is copied to the/tftpboot directory:
[[Email protected]]# rpm-ql Syslinux | grep "pxelinux.0"
/usr/lib/syslinux/pxelinux.0
[[Email protected]]# cp/usr/lib/syslinux/pxelinux.0/tftpboot/
Configure the configuration file used by the pxelinux.0 (NBP)
Next, create the/tftpboot/pxelinux.cfg/directory, which is used to store the client's configuration file
[[Email protected]]# mkdir/tftpboot/pxelinux.cfg
Default configuration file, file contents are as follows,
[[Email protected]]# Cat/tftpboot/pxelinux.cfg/default
Default Linux # starts with the boot kernel labeled ' label Linux '
Prompt 1 # show ' Boot: ' Prompt
Timeout 60 # Wait timeout, unit 1/10 seconds, automatically start default specified label after timeout
Display Boot.msg # Displays the contents of boot.msg, the file path is relative to the root directory of the TFTP server (default/tftpboot), so the boot.msg file absolute path is in/tftpboot/boot.msg.
F1 Boot.msg # Press the ' F1 ' key to display the file
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
Label 1 # ' label ' specifies the keyword you entered at the ' Boot: ' Prompt.
Kernel Linux/rh44-x86-32/vmlinuz
Append initrd=linux/rh44-x86-32/initrd.img ramdisk_size=8192 ks=http://install.test.com/conf/ks_module.cfg Ksdevice=link
Label 2
Kernel Linux/rh44-x86-64/vmlinuz
Append initrd=linux/rh44-x86-64/initrd.img ramdisk_size=8192 ks=http://install.test.com/conf/ks_module.cfg Ksdevice=link
Label 3
Kernel Linux/rh46-x86-64/vmlinuz
Append initrd=linux/rh46-x86-64/initrd.img ramdisk_size=8192 ks=http://install.test.com/conf/ks_module.cfg Ksdevice=link
Label 4
Kernel Linux/rh46-x86-32/vmlinuz
Append initrd=linux/rh46-x86-32/initrd.img ramdisk_size=8192 ks=http://install.test.com/conf/ks_module.cfg Ksdevice=link
Label 5
Kernel Image/linux/rh38-x86-32/vmlinuz
Append initrd=image/linux/rh38-x86-32/initrd.img ramdisk_size=8192 ks=http://install.test.com/conf/ks_module.cfg Ksdevice=link
Label 6
Kernel Linux/rh38-x86-64/vmlinuz
Append initrd=linux/rh38-x86-64/initrd.img ramdisk_size=8192 ks=http://install.test.com/conf/ks_module.cfg Ksdevice=link
Note: The default pxelinux.0 and Pxelinux.cfg must be in the same directory
3.3. pxelinx.0 (NBP) program configuration file Search Order
Because multiple clients can boot from a PXE server, the PXE boot image uses a complex configuration file search method to locate the profile for the client.
Assuming the MAC address of the client server's NIC is 88:99:AA:BB:CC:DD and the corresponding IP address is 192.168.1.195, then the client's pxelinux.0 program search order is as follows:
A configuration file that matches the file name of the MAC address first, and if it does not exist, continues to find.
Second, look for the IP address. Based on the IP address 16 binary named configuration file lookup, from small to large to hit the size of the lookup (subnet mask from small to large), if not present, continue to find.
Finally try the default file
In general, the order in which files are searched by pxelinux.0 (results can be obtained by tcpdum):
/tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd
/tftpboot/pxelinux.cfg/c0a801c3
/tftpboot/pxelinux.cfg/c0a801c
/tftpboot/pxelinux.cfg/c0a801
/tftpboot/pxelinux.cfg/c0a80
/tftpboot/pxelinux.cfg/c0a8
/tftpboot/pxelinux.cfg/c0a
/tftpboot/pxelinux.cfg/c0
/tftpboot/pxelinux.cfg/c
/tftpboot/pxelinux.cfg/default
4. Summary (Summary)
Detailed implementation of the PXE server deployment process under Linux system