Document directory
- 1. Glossary used in this article
- 2. PXE Principle
- 3. PXE boot server configuration process
- 4. Summary)
1. Glossary used in this article
-
PXE
-
PXE (pre-boot executionenvironment) is an Intel-designed protocol that enables computers to be started over the network rather than from local hard drives, optical drives, and other devices. Modern NICs are usually embedded with Rom chips that support PXE. During computer boot, the BIOS transfers the PXE client to the memory for execution and displays the command menu. After the user selects the command, the pxeclient downloads the pxeclient from the remote operating system to the local computer for running.
-
DHCP
-
DHCP (Dynamic Host Control Protocol) Dynamic Host Control Protocol. Used to centrally and dynamically assign IP addresses to clients.
-
TFTP
-
TFTP (Trivial File Transfer Protocol) is a File Transfer Protocol with a low overhead. The syntax is similar to FTP. Because of its simplicity and efficiency, it is often used to update operating systems and configurations of network devices.
2. PXE principle 2.1. PXE client API (Architecture)
Figure pxe api Architecture. (Image Source: PXE Specification Version 2.1)
Note: When the BIOS loads the PXE client into the memory, it has the capabilities of DHCP Client and TFTP client.
PXE client is capable of DHCP Client and can obtain IP addresses through DHCP server.
PXE client is capable of TFTP client. You can use TFTP to download files such as kernel image.
2.2. PXE boot flowchart (PXE boot)
The startup process is described as follows:
- The PXE client broadcasts the dhcpddiscover message to the UDP port 67.
- After receiving the broadcast message, DHCP server or DHCP proxy sends the dhcpoffer (including the IP address) message to port 68 of PXE client.
- The PXE client sends the dhcprequest message to the DHCP server to obtain the boot file name ).
- DHCP server sends the dhcpack (including network Bootstrap program file name) message to PXE client.
- PXE client obtains the NBP (Network Bootstrap program) file from the boot server.
- PXE client downloads NBP from the TFTP server, and then executes the NBP file on the client.
Note: After NBP executes initialization, NBP downloads other required configuration files from the TFTP server by default.
At this time, the PXE startup process has been completed, and the rest of the work is completed with NBP.
For example, pxelinux.0 (NBP) downloads the default configuration file to display the menu and starts different kernel images as needed.
If it is the NBP of RIS (Windows installation), Windows boot loader is started to execute the widows installation and deployment task.
3. PXE boot server configuration process
The following configurations and tests are completed on centos5. For more information about other systems, see!
3.1. DHCP installation and configuration
During the PXE boot process, the PXE client obtains the IP address and NBP file name through the DHCP server, downloads the NBP file from the TFTP server, and runs the file on the client to start the computer.
- Verify that the DHCP software package is installed in the system.
- Edit the/etc/DHCPD. conf configuration file. The configuration file content is as follows:
[Root @ Linux] # Cat/etc/DHCPD. conf
Ddns-Update-style interim;
Allow booting; # define the ability to start PXE
Allow BOOTP; # define support for 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: In the/etc/DHCPD. conf configuration fileFilename "pxelinux.0 ";
The file directory is the root directory (/tftpboot by default) relative to TFTP ),
Therefore, the absolute path of the file is/tftpboot/pxelinux.0 ". You can also specify it as another path.
- After the configuration is complete, restart the DHCP service and set it to boot automatically
[Root @ Linux] #/etc/init. d/DHCPD start
Start DHCPD: [OK]
[Root @ Linux] # chkconfig -- level 35 DHCPD on
3.2. install and configure the TFTP Server
During the PXE boot process, the PXE client uses the TFTP protocol to download and execute the bootstrap file from the TFTP server.
- Verify that the TFTP-server software 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 and change disable = yes to disable = No. The configuration file content is as follows: [root@linux]# 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 printers, /
# 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 printers, /
#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= 11
cps= 100 2
flags= IPv4
}
Note: the root directory of the TFTP server is/tftpboot. After the configuration is complete, restart the xinetd service to make the TFTP server take effect.
[root@linux]# /etc/init.d/xinetd restart
- The bootstrap file configuration (NBP) is provided by the syslinux software package. If syslinux is installed, copy the pxelinux.0 file to the/tftpboot directory:
[root@linux]# rpm -ql syslinux | grep "pxelinux.0"
/usr/lib/syslinux/pxelinux.0
[root@linux]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
- Configure the configuration file used by pxelinux.0 (NBP)
- Next, create the/tftpboot/pxelinux. cfg/directory to store the client configuration file.
[root@linux]# mkdir /tftpboot/pxelinux.cfg
- The default configuration file is default. The file content is as follows:
[Root @ Linux] # Cat/tftpboot/pxelinux. cfg/Default
Default Linux # by default, the startup kernel marked in 'label Linux 'is started.
Prompt 1 # display 'boot: 'prompt
Timeout 60 # Wait time-out period, in the unit of 1/10 seconds. After timeout, the default label is automatically started.
Display boot. MSG # display boot. MSG content, the file path is relative to the root directory of the TFTP server (default/tftpboot), so boot. the absolute path of the MSG file is/tftpboot/boot. MSG.
F1 boot. MSG # file displayed after pressing 'f1'
F2 options. msg
F3 General. msg
F4 Param. msg
F5 rescue. msg
Label 1 # 'label' specifies the keyword you enter 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: pxelinux.0 and pxelinux. cfg must be in the same directory by default.
3.3. pxelinx.0 (NBP) program configuration file search sequence
Since multiple clients can boot from a PXE Server, the PXE Boot Image uses a complex configuration file search method to find the configuration file for the client.
Assume that the MAC address of the NIC of the client server is 88: 99: AA: BB: CC: DD and the corresponding IP address is 192.168.1.195. The pxelinux.0 program search order of the client server is as follows:
- First, use the MAC address as the configuration file that matches the file name. If it does not exist, continue searching.
- Second, search by IP address. Search by configuration file named in hexadecimal format of IP address, from small to large, divided into search (subnet mask from small to large). If it does not exist, continue to search.
- Finally try the default file
In general, the order of the files searched by pxelinux.0 is (the result can be obtained through 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)
5. ks. cfg file of PXE ---- memo
# Kickstart file automatically generated by Anaconda.
Install
URL -- URL http: // 192.168.1.100/centos4.5
Lang en_us
Langsupport -- default = en_US.UTF-8 zh_CN.UTF-8 en_US.UTF-8
Keyboard us
Mouse
Text
# Xconfig -- card "ATI es1000" -- videoram 16384 -- hsync 28-64 -- vsync 48-78 -- resolution 800x600 -- depth 16
Network -- device eth0 -- bootproto static -- IP 192.168.1.200 -- netmask 255.255.255.0 -- gateway = 192.168.1.1 -- hostname = test.insenz.com
Rootpw -- iscrypted $1 $ U // jmrgx $ dw9ytxblcyaafvkvwocnf0
Firewall -- disabled
SELinux -- disabled
Authconfig -- enableshadow -- enablemd5
Timezone Asia/Shanghai
Bootloader -- location = MBR
Zerombr Yes
Clearpart -- Linux -- initlabel
Part/boot -- fstype ext3 -- size = 150 -- ondisk = SDA -- asprimary
Part swap -- size = 4096 -- ondisk = SDA
Part/-- size = 20480 -- fstype ext3 -- ondisk = SDA
Part/home -- fstype ext3 -- size = 1 -- grow -- ondisk = SDA
Part/data -- fstype ext3 -- size = 1 -- grow -- ondisk = SDB
Skipx
% Packages -- resolvedeps
@ Editors
@ Emacs
@ System-Tools
@ X-software-development
@ Dialup
@ Chinese-support
@ Development-Tools
-Ckermit
Kernel-devel
Kernel-smp-devel
-Bluez-pin
-Gamin-devel
-Openipmi-Tools
Vlock
Iptraf
Lslk
E2fsprogs
-Xdelta
-Zsh
Sysstat
Kernel-SMP
Grub
-Iiimf-libs-devel
% Post