Preparation:
DHCP server
TFTP Server
FTP Server
Kickstart File
A client with a pxe rom chip that supports Network startup, that is, a bare metal that requires system installation
Linux image files
Here, a host provides DHCP, TFTP, and FTP services at the same time, and kickstart is also deployed on this server.
Principle
The remote client computer starts. Because the BIOS sets the NIC to start, the program in the pxe rom of the NIC is transferred to the memory for execution. First, the client finds the DHCP server in the network and then requests an IP address. At the same time, the DHCP server contacts the TFTP server and sends a bootstrap (Bootstrap program) to the client ). After the client receives the bootstrap (File pxelinux.0) and runs the command, bootstrap requests TFTP to transfer the bootstrap configuration file (pxelinux. cfg ). Read the configuration file after receiving it. The client requests TFTP to transfer the kernel image file (vmlinuz) and the root file system file (initrd. IMG) based on the configuration file content and customer information ). Finally, start the kernel. This is a complete PXE build process. However, to enable the NIC to start and then install the system on the network, the FTP service also needs to place the required installation files in the FTP directory for transmission and installation.
Install
#yum –disablerepo=\* --enablerepo=c5-mediainstall dchp* tftp* ftp* system-config-kickstart*
Configuration Service
After DHCP is installed, the configuration file is empty. We can modify it according to the sample in the document.
[root@pxe ~]# cat/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample >> /etc/dhcpd.conf
Then modify its content
[Root @ PXE ~] # Vi/etc/DHCPD. confddns-Update-style interim; ignore client-updates; allow booting; # Add allow BOOTP; # Add subnet 192.168.128.0 netmask 255.255.0 {# --- Default Gateway option routers 192.168.128.1; option subnet-mask limit 255.0; Option Nis-domain "domain.org"; Option domain-name "domain.org"; # option domain-name-servers 192.168.128.1; # comment this row, to speed up enabling option time-offset-18000; # Eastern Standard Time # option NTP-servers 192.168.1.1; # option NetBIOS-name-servers 192.168.1.1; # --- selects point-to-point node (defaultis hybrid ). don't change this unless # -- you understand NetBIOS very well # option NetBIOS-node-type 2; range dynamic-BOOTP 192.168.128.150 192.168.128.200; FILENAME "/pxelinux.0 "; # specify the Startup File next-server 192.168.128.111; # specify the Server IP address default-lease-time 21600; max-lease-time 43200; # We want the nameserver to appear at a fixed address host NS {next-server marvin.redhat.com; hardware ethernet12: 34: 56: 78: AB: CD; fixed-address 207.175.42.254 ;}}
Modify the configuration of TFTP
[Root @ PXE ~] # Cat/etc/xinetd. d/TFTP # default: off # Description: the TFTP server serves filesusing the Trivial File Transfer \ # protocol. the tftp protocol isoften 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 # change Yes to no per_source = 11 CPS = 100 2 flags = IPv4}
FTP uses Anonymous logon and the default directory/var/ftp. The configuration is not modified. You only need to put the Linux image file under/var/FTP.
[root@pxe ~]# ls /var/ftp/cdrom/CentOS images RELEASE-NOTES-cs RELEASE-NOTES-de.html RELEASE-NOTES-en_US RELEASE-NOTES-es.html RELEASE-NOTES-ja RELEASE-NOTES-nl.html RELEASE-NOTES-ro RPM-GPG-KEY-betaEULA isolinux RELEASE-NOTES-cs.html RELEASE-NOTES-en RELEASE-NOTES-en_US.html RELEASE-NOTES-fr RELEASE-NOTES-ja.html RELEASE-NOTES-pt_BR RELEASE-NOTES-ro.html RPM-GPG-KEY-CentOS-5GPL NOTES RELEASE-NOTES-de RELEASE-NOTES-en.html RELEASE-NOTES-es RELEASE-NOTES-fr.html RELEASE-NOTES-nl RELEASE-NOTES-pt_BR.html repodata TRANS.TBL
After the TFTP service is installed, a/tftpboot directory will be created. This directory is used to place the bootstrap Boot Program (pxelinux.0), bootstrap configuration file (default), and kernel image (vmlinuz) and file system files (initrd. IMG. Here we need to first create a pxelinux. cfg directory and put the default file under it.
[Root @ PXE ~] # Ll/tftpboot/total 9828-rw-r -- r -- 1 Root 8056614 04-18 00: 57initrd. IMG-RW-r -- 1 Root 13148 04-19 20:22 pxelinux1_drwxr-XR-x 2 root Root 4096 04-20 pxelinux. CFG-RW-r -- 1 Root 1953660 04-19 20: 21 vmlinuz [root @ PXE ~] # Ll/tftpboot/pxelinux. cfg/total 8-rwxr-xr-x 1 Root 396 04-19 22: 03 default
Source of the above four files:
[root@pxe ~]# cp/usr/lib/syslinux/pxelinux.0 /tftpboot/[root@pxe ~]# cd /var/ftp/cdrom/isolinux/[root@pxe isolinux]# pwd/var/ftp/cdrom/isolinux[root@pxe isolinux]# cp initrd.imgisolinux.cfg vmlinuz /tftpboot/
Here, isolinux. cfg is our default file. We need to rename it and put it under the pxelinux. cfg directory.
[root@pxe tftpboot]# mkdir pxelinux.cfg/[root@pxe tftpboot]# mv isolinux.cfgpxelinux.cfg/[root@pxe tftpboot]# cd pxelinux.cfg/[root@pxe pxelinux.cfg]# mv isolinux.cfgdefault
We also need some settings for the default file.
[Root @ PXE pxelinux. CFG] # vi defaultdefault linuxprompt 1 timeout 600 display boot. msgf1 boot. msgf2 options. msgf3 general. msgf4 Param. msgf5 rescue. msglabel Linux kernel vmlinuz # Ks = ftp: // 192.168.128.111/KS. CFG points to the file on the FTP server/var/ftp. This file is the response file installed in Linux, that is, the Kickstart file append Ks = ftp: // 192.168.128.111/KS. CFG initrd = initrd. imglabel text kernel vmlinuz append initrd = initrd. IMG textlabel KS kernel vmlinuz append KS initrd = initrd. imglabel local localboot 1 label memtest86 kernel memtest append-
For more information about how to create a kickstart file, see configure and use Kickstart.
Put the KS. cfg file under/var/FTP.
[Root @ pxe ftp] # ll total 24drwxr-xr-x 7 Root 4096 04-19 23: 04cdrom-rw-r -- r -- 1 Root 1399 04-20 20: 41ks. unzip drwxr-XR-x 2 root Root 4096 04-20 20:43 pub
Start the service
Start Dhcp Service
[root@pxe ftp]# service dhcpd start
Start the TFTP service
[root@pxe ftp]# service xinetd start
Start FTP service
[root@pxe ftp]# service vsftpd start
Now, the server configuration is complete.
Start the bare metal instance from the network.