20.1 C
Texas
Muhammad Nabeel
Network and System Administrator

Install PXE Boot server for automated install Centos7

In computing, the Preboot eXecution Environment (PXE, sometimes pronounced as pixie[1]) specification describes a standardized client-server environment that boots a software assembly, retrieved from a network, on PXE-enabled clients. On the client side it requires only a PXE-capable network interface controller (NIC), and uses a small set of industry-standard network protocols such as DHCP and TFTP.

In this article you will learn how to install and configure PXE Server on RHEL/CentOS 7 with local installation repositories using DNSMASQ Server.

Step 1: Install and configure DNSMASQ Server

Use the following command to install DNSMASQ daemon

# yum install dnsmasq -y

- Advertisement -

Now edit /etc/dnsmasq.conf file.
backup the old file and create new one to make configuration in it for safety.

# mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup

# vi /etc/dnsmasq.conf

Replace below settings according to system and network in /etc/dnsmasq.conf

interface=ens33,lo
#bind-interfaces
domain=localhost.localdomain.local
# DHCP range-leases
dhcp-range= ens33,192.168.130.138,192.168.130.253,255.255.255.0,1h
# PXE
dhcp-boot=pxelinux.0,pxeserver,192.168.130.138
# Gateway
dhcp-option=3,192.168.130.2
# DNS
dhcp-option=6,92.168.130.2, 8.8.8.8
server=8.8.4.4
# Broadcast Address
dhcp-option=28,192.168.130.255
# NTP Server
dhcp-option=42,0.0.0.0

pxe-prompt="Press F9 for menu.", 30
pxe-service=x86PC, "Install CentOS 7 from PXE server 192.168.130.138", pxelinux
enable-tftp
tftp-root=/var/lib/tftpboot

Step 2: Install SYSLINUX Bootloaders

Now install Syslinx PXE bootloader package by using following command.

# yum install syslinux -y

Step 3: Install and configure TFTP Server with SYSLINUX Bootloaders

First install TFTP-Server using following command.

# yum install tftp-server -y

Now copy all Syslinux bootloder files from /usr/share/syslinux to /var/lib/tftpboot path, using following commands.

# cp -r /usr/share/syslinux/* /var/lib/tftpboot

Step 4: Configuration PXE Server File

Create directory pxelinux.cfg and configure it with a default file using following commands.

# mkdir /var/lib/tftpboot/pxelinux.cfg

# touch /var/lib/tftpboot/pxelinux.cfg/default

Now edit PXE configuration file with Centos installation option. Note that all paths used in this file must be placed in /var/lib/tftpboot directory.

Below you can see an demo configuration file which you can use, but modify the installation images (kernel and initrd files), protocols (FTP, HTTP, HTTPS, NFS) and IPs to reflect your network installation source repositories and paths accordingly.

# vi /var/lib/tftpboot/pxelinux.cfg/default

Now Add below configuration in /var/lib/tftpboot/pxelinux.cfg/default file.
Note: Replace IP address with your own.

default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

label 1
menu label ^1) Install CentOS 7 with Local Repo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=ftp://192.168.130.138/pub devfs=nomount

label 2
menu label ^2) Boot from local drive

 

Step 5: Add CentOS 7 Boot Images to PXE Server

In this step CentOS kernel and initrd files are required. I will copy these files from CENTOS 7 bootable USB. You can copy these files from CentOS DVD, Just put Centos DVD in your DVD drive and mount the image to /mnt path by issuing the below command.

# mount -o loop /dev/cdrom /mnt

# ls /mnt

Now create centos7 folder and copy CentOS bootable kernel and initrd images from the DVD mounted location to centos7 folder.

# mkdir /var/lib/tftpboot/centos7

# cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7

# cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/centos7

Step 6: Create CentOS 7 Local Installation Source

To make local installation source, Install vsftpd packgae, copy all content from DVD to vsftpd path /var/ftp/pub and set permissions to pub folder by using following commands.

Note: copy of the DVD image will take some time on this step.

# yum install vsftpd

# cp -rv /mnt/* /var/ftp/pub/

# chmod -R 755 /var/ftp/pub

Step 7: Start and Enable installed services

# systemctl start dnsmasq

# systemctl start vsftpd

# systemctl enable dnsmasq

# systemctl enable vsftpd

Step 8: Allow Necessary Services and Ports in Firewalld

firewall-cmd --permanent --add-service={ftp,dns,dhcp}

firewall-cmd --permanent --add-port={69/udp,4011/udp}

firewall-cmd --reload

Step 9: Boot Clients from Network

Clients PC’s must be on same network to boot from network, so make sure of it

In order to choose network booting. After first PXE prompt appears, press F8 key to enter

and then hit Enter key to proceed forward to PXE menu.

That’s it, After that Centos 7 installation screen will be shown.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article