Pre-requirement & reference:
Understand how to enable PXE at Client machine, refer to FWA-2012 I210 PXE function setting – Advantech Cloud IoT Service Portal (zendesk.com).
Purpose:
Describes how to configure TFTP and DHCP on a PXE (Preboot execution Environment) server to enable PXE boot and network installation.
Here is configuring IPv4 PXE for Client in Legacy (X86 BIOS) when boot-loader file is "pxelinux.0"
Note: attached DOS bootable image and following necessary (reference) files
Install the necessary service(packages)
# yum install xinetd dhcp tftp tftp-server vsftpd syslinux httpd
Configure DHCP service
eth0
, eth1
, and eth2
— and it is only desired that the DHCP daemon listens on the eth0
card, then only specify eth0
in /etc/sysconfig/dhcpd
:# vim /etc/sysconfig/dhcpd
# cat /etc/sysconfig/dhcpd |grep -i dhcpargs
DHCPDARGS="eth0";
# cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf_bk
# vim /etc/dhcp/dhcpd.conf
// Following is my setting, the DHCP domain in 192.168.17.x
// DO NOT forget to set server ip (ex. 192.168.17.99) to your PXE providing port
// If your PXE server is for production use case, you may shorten the lease time to avoid run out of free lease IP address.
# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
Authoritative;
# Default lease time for a day in second
default-lease-time 86400;
# Max lease time for 10 days in seconds
max-lease-time 864000;
option routers 192.168.17.254;
option broadcast-address 192.168.17.255;
option subnet-mask 255.255.255.0;
option domain-name-servers 168.95.1.1,140.111.66.1,8.8.8.8;
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
allow unknown-clients;
server-name pxis;
subnet 192.168.17.0 netmask 255.255.255.0 {
range 192.168.17.100 192.168.17.150;
option subnet-mask 255.255.255.0;
option domain-name "TSE";
next-server 192.168.17.99;
filename "pxelinux.0";
}
Copy tftpboot folder to /
# cp -r /var/lib/tftpboot/ /
Configure TFTP service
// Following is my setting, the tftp folder is under /
# 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.
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
}
Change authority for files
# mkdir /tftpboot/netboot
# chmod 644 /tftpboot/netboot/*
# chmod 755 /tftpboot
Set up & Check the boot menu
# mkdir /tftpboot/pxelinux.cfg
# vi /tftpboot/pxelinux.cfg/default
//Following is my setting, now the 1st is boot from FreeDOS (DOS)
default menu.c32
prompt 0
timeout 30
MENU TITLE example.com PXE Menu
LABEL DOS
MENU LABEL DOS
KERNEL /netboot/memdisk
APPEND initrd=/netboot/freeDOSboot.img console=ttyS0,115200
#LABEL CentOS7_x64
#MENU LABEL CentOS 7.3 x86_64
#KERNEL /netboot/vmlinuz
#APPEND initrd=/netboot/initrd.img inst.repo=ftp://192.168.17.99/pub console=ttyS0,115200
#ks=ftp://192.168.17.99/pub/ks.cfg
For example, if you want to install CentOS from PXE, you may leverage the following steps
- mount CentOS ISO to the temporary folder
# mount -o loop CentOS-7-x86_64-Minimal-1804.iso /mnt/
- copy files from mounted iso to /var/ftp/pub
# cp -a /mnt/* /var/ftp/pub
- copy bootable kernel files to /tftpboot
# cd /var/ftp/pub/images/pxeboot/
# cp vmlinuz initrd.img /tftpboot/netboot
# chmod 644 /tftpboot/netboot/*
- copy boot loader files from syslinux
# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
# cp /usr/share/syslinux/menu.c32 /tftpboot/
- untag the menu in PXE boot menu , following as a reference (ignore kickstar ks file)
- Manually add blacklist in grub (red marked in below) may be required due to Linux compatibility with some PCH (ex. LBG-E/M/T/L)
default menu.c32
prompt 0
timeout 30
MENU TITLE example.com PXE Menu
LABEL DOS
MENU LABEL DOS
KERNEL /netboot/memdisk
APPEND initrd=/netboot/freeDOSboot.img console=ttyS0,115200
LABEL CentOS7_x64
MENU LABEL CentOS 7.3 x86_64
KERNEL /netboot/vmlinuz
APPEND initrd=/netboot/initrd.img inst.repo=ftp://192.168.17.99/pub console=ttyS0,115200 modprobe.blacklist=ipmi_ssif,qat_c62x,qat_dh895xcc,qat_c3xxx,intel_qat
#ks=ftp://192.168.17.99/pub/ks.cfg
Allow services in Firewall settings
# firewall-cmd --permanent --add-service=dhcp
# firewall-cmd --permanent --add-service=ftp
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=tftp
# firewall-cmd --reload
Change SELinux Settings
# restorecon -F -R -v /tftpboot
# restorecon -R -F -v /var/ftp/pub/
Start Services
# systemctl start tftp
# systemctl enable tftp
# systemctl start xinetd
# systemctl enable xinetd
# netstat -tulnp | grep xinetd
# systemctl start vsftpd
# systemctl enable vsftpd
# systemctl start dhcpd
# systemctl enable dhcpd
Comments
0 comments
Please sign in to leave a comment.