KB 101019 - How to make PXE_Boot script

KB 101019 - How to make PXE_Boot script

Introduction of PXE booting

PXE (Pre-Boot Execution Environment) booting is a technology that enables a computer to boot from a network device, rather than a local hard drive or other storage media. PXE booting is commonly used in enterprise environments to automate the deployment of operating systems and software applications on a large scale.

With PXE booting, a client computer first requests an IP address from a DHCP (Dynamic Host Configuration Protocol) server, then requests the location of a boot server from a TFTP (Trivial File Transfer Protocol) server. The boot server provides the client computer with the necessary files to boot, including the operating system, drivers, and other software.

PXE booting provides several benefits, including faster deployment and provisioning of operating systems and applications, and reduced administrative overhead. It also enables centralized management of operating systems and software applications, ensuring that they are consistent and up-to-date across all client computers.

PXE booting is commonly used in combination with other technologies, such as containerization and virtualization, to automate the deployment and management of software applications in large-scale environments.



System Requirements

Hardware requirements:

  1. RAM: 8 GB (Preferred 16)
  2. PROCESSOR: i5 10 gen
  3. SSD: 256GB

Software requirements:

  1. VMware workstation
  2. Centos7 iso
  3. Editor: - vi/vim/nano

Virtual Machine Requirement for Master Node

  1. RAM: 4GB
  2. Cores: 2
  3. Storage: 50GB
  4. OS: Centos 7 (Linux)
  5. Network Adapter: 2
    1. NAT
    2. Custom


Prerequisite For Creating a PXE Cluster

Disable SELinux:

  1.       vim /etc/selinux/config


Stop & Disable Firewall:

  1. systemctl stop firewalld
  2. systemctl disable firewalld
  3. systemctl status firewalld


Code

  1. Crate a file in any editor (vi/vim/nano) and paste all following code
  2. Save to [file_name].sh
  3. For example- pxe_boot_script.sh
  4. Change file permission to rwx(777)
  5. Execute script using command (./[file_name].sh) or ( bash [file_name].sh
  6. For example 1) ./pxe_boot_script.sh           2). bash pxe_boot_script.sh
  7. User inputs after execution: - Provide only necessary IP addresses like
  8. Server IP address (Master Node)
  9. Subnet
  10. Network Mask
  11. Starting IP Range (for DHCP pool ip)
  12. Ending IP Range (for DHCP pool ip)

Install all necessary packages

  1. yum install -y dhcp* syslinux xinetd tftp-server httpd
Description: - yum is a package installer, this code installs necessary packages like: - DHCPD (for IP Address pool and lease), SYSLINUX, XINTED TFTP-SERVER and HTTPD.

Configure dhcpd network

  1. tee /etc/dhcp/dhcpd.conf<<EOF
  2. #host_change=server Host ip, subnet_change=subnet, netmask_change=netmask, range_start=starting ip, range_end=ending ip,
  3. option domain-name "host_change";
  4. subnet subnet_change netmask netmask_change{
  5. range range_start range_end;
  6. option routers host_change;
  7. filename "pxelinux.0";
  8. next-server host_change;
  9. }
  10. EOF
Description: - TEE command is use stdin to stdout, (save inputs to a file), This code configure DHCP network, assigning SERVER IP, SUBNET, NETWORK MASK, POOL RANGE. All this inputs will provide by user after execution of script.

User Input

  1. #read ip address, subnet, netmask, and DHCP network range from user
  2. read -p "enter server ip: " s_ip
  3. read -p "enter subnet mask: " sub_ip
  4. read -p "enter netmask: " net_ip
  5. read -p "enter starting ip range:" start_ip
  6. read -p "enter ending ip range:" end_ip
  7. sed -i -e "s/host_change/${s_ip}/g" /etc/dhcp/dhcpd.conf
  8. sed -i -e "s/subnet_change/${sub_ip}/g" /etc/dhcp/dhcpd.conf
  9. sed -i -e "s/netmask_change/${net_ip}/g" /etc/dhcp/dhcpd.conf
  10. sed -i -e "s/range_start/${start_ip}/g" /etc/dhcp/dhcpd.conf
  11. sed -i -e "s/range_end/${end_ip}/g" /etc/dhcp/dhcpd.conf
  12. #make directory
  13. mkdir /var/lib/tftpboot/pxelinux.cfg
  14. #copy pxelinux.0 file to newly created direcoty
  15. cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
Description: - User provides the all IP Address and pool range, script automatically changes the values to all the configuration files.

Configure xinted file

  1. #configure xinted file
  2. tee /etc/xinetd.d/tftp<<EOF
  3. #default: off
  4. #description: The tftp server serves files using the trivial file transfer \
  5. #protocol.  The tftp protocol is often used to boot diskless \
  6. #workstations, download configuration files to network-aware printers, \
  7. #and to start the installation process for some operating systems.
  8. service tftp
  9.       {
  10.       socket_type          = dgram
  11.       protocol                 = udp
  12.       wait                        = yes
  13.       user                        = root
  14.       server                     = /usr/sbin/in.tftpd
  15.       server_args           = -s /var/lib/tftpboot
  16.       disable                   = no
  17.       per_source            = 11
  18.       cps                          = 100 2
  19.       flags                       = IPv4
  20.       }
  21. EOF
  1. #create a directory and copy all boot related files
  2. mkdir -p /var/pxe/centos7
  3. mkdir -p /var/lib/tftpboot/centos7
  4. mount -t iso9660 -o loop /dev/cdrom /var/pxe/centos7/
  5. cp /var/pxe/centos7/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7/
  6. cp /var/pxe/centos7/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/
  7. cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/ 

Configure pxelinux.cfg file

  1. #configure pxelinux.cfg file
  2. tee /var/lib/tftpboot/pxelinux.cfg/default<<EOF
  3. #server_ip
  4. timeout 100
  5. default menu.c32
  6. menu title #######PXE BOOT MENU####
  7. label 1
  8.       menu label ^1) Install centos7
  9.      kernel centos7/vmlinuz
  10.                      append initrd=centos7/initrd.img ks=http://host_change/ks/centos7-ks.cfg method=http://host_change/centos7/ devfs=nomount
  11. label 2
  12.       menu label ^2) Boot from local drive
  13.                     localboot
  14. EOF
  15. sed -i -e "s/host_change/${s_ip}/g" /var/lib/tftpboot/pxelinux.cfg/default

Configure pxeboot.conf file

  1. #configure pxeboot.conf file
  2. tee /etc/httpd/conf.d/pxeboot.conf<<EOF
  3. #subnet_ip
  4. Alias /centos7 /var/pxe/centos7
  5. <Directory /var/pxe/centos7>
  6. options Indexes FollowSymlinks
  7. Require ip 127.0.0.1 subnet_change/24
  8. </Directory>
  9. EOF
  10. sed -i -e "s/subnet_change/${sub_ip}/g" /etc/httpd/conf.d/pxeboot.conf

Kickstart file

  1. #kickstart
  2. #python -c 'import crypt,getpass;print(crypt.crypt(getpass.getpass(),crypt.mksalt(crypt.METHOD_SHA512)))' > pass.txt
  3. mkdir /var/www/html/ks
  4. tee /var/www/html/ks/centos7-ks.cfg<<EOF
  5. #create new
  6. install
  7. # automatically proceed for each steps
  8. autostep
  9. #reboot after installing
  10. reboot
  11. #encrypt algorithm
  12. auth --enableshadow --passalgo=sha512
  13. #installation source
  14. url --url=http://host_change/centos7/
  15. # install disk
  16. ignoredisk --only-use=sda
  17. # keyboard layouts
  18. keyboard --vckeymap=jp106 --xlayouts='jp','us'
  19. # system locale
  20. lang en_US.UTF-8
  21. # network settings
  22. network --bootproto=dhcp --ipv6=auto --activate --hostname=localhost
  23. #root password you generated above
  24. #rootpw --iscrypted < pass.txt
  25. #timezone
  26. timezone Asia/Tokyo --isUtc --nontp
  27. #bootloader's settings
  28. bootloader --location=mbr --boot-drive=sda
  29. #initialize all partition tables
  30. zerombr
  31. clearpart --all --initlabel
  32. #partitioning
  33. autopart --type=lvm
  34. #part /boot --fstype="xfs" --ondisk=sda --size=500
  35. #part pv.10 --fstype="lvmpv" --ondisk=sda --size=51200
  36. #volgroup VolGroup --pesize=4096 pv.10
  37. #logvol / --fstype="xfs" --size=20480 --name=root --vgname=VolGroup
  38. #logvol swap --fstype="swap" --size=4096 --name=swap --vgname=VolGroup
  39. %packages
  40. @core
  41. %end
  42. EOF
  43. sed -i -e "s/host_change/${s_ip}/g" /var/www/html/ks/centos7-ks.cfg

Start all the services

  1. systemctl start xinetd
  2. systemctl enable xinetd
  3. systemctl start httpd
  4. systemctl enable httpd
  5. systemctl start dhcpd
  6. systemctl enable dhcpd
  7. systemctl start tftp
  8. systemctl enable tftp

Screenshots of output

User provides IP Addresses


DHCP file created after execution

pxelinux.cfg

pxeboot.conf file



xinted file

Kickstart File



for full script please click here


    • Related Articles

    • KB 054003 - How to create Virtual Machine in VMWare

      What is Virtualisation Virtualization is technology that lets you create useful IT services using resources that are traditionally bound to hardware. It allows you to use a physical machine’s full capacity by distributing its capabilities among many ...
    • KB 361001 - What is Boot Process in Linux OS.

      Boot Process in Linux OS. Have you ever wondered what happens behind the scenes from the time you press the power button until the Linux login prompt appears? Press the power button on your system, and after few moments you see the Linux login ...
    • KB 686001 - ASUS Server Stress Testing Guide for INTEL and AMD Platforms

      Creating a Bootable USB with Asus Test Tool Step 1: Download Required Files Download Asus Linux Image: Save the Linux image file provided by Asus. Download Memtest Tool: Open a browser, search for "Memtest," and download the free version from the ...
    • KB 158059 - How to collect diagnostic logs using the NetApp Log Collection Script

      1. Purpose This document describes the procedure to collect diagnostic logs using the NetApp Log Collection Script in environments running: BeeGFS NetApp E-Series backend storage HA cluster using Pacemaker and Corosync This script is typically ...
    • KB 470118 - Troubleshooting on Server Network Speed

      Steps to troubleshoot speed on server for 10G NIC Verify Network Configuration Network Adapter Settings: Check the settings of the Intel® Dual Port X710-T2L 10-Gigabit Ethernet Network Adapter on each server. Ensure that the adapter is configured for ...
    • Recent Articles

    • KB 626274 - Re-Activating Windows 11 Pro After a Motherboard Replacement

      Overview After a motherboard replacement, Windows may show a message such as "Windows is not activated" because it no longer recognizes your computer's hardware. You can usually fix this yourself in 10 to 30 minutes by following the steps below. Your ...
    • KB 503990 - Architectural Difference Between NVIDIA HGX and DGX

      Architectural Difference Between NVIDIA HGX and DGX KB Article – Web Publication Overview NVIDIA HGX and DGX are both high-performance AI computing platforms built around multi-GPU NVIDIA accelerators, NVLink/NVSwitch technology, and high-speed ...
    • KB 148090 - Install an OS remotely via ASUS IPMI's KVM

      Here's how to install an OS remotely via ASUS IPMI's KVM (Java or HTML5-based remote console): 1. Access the BMC web interface. Connect to the ASUS IPMI/ASMB management LAN port (separate from the server's normal NICs). Browse to ...
    • KB 114035 - Zotac RMA Process

      ZOTAC RMA PROCESS Overview This plan outlines the overall operational support process for ZOTAC hardware supported by Mbuzz, covering warranty validation, technical diagnosis, RMA coordination, replacement and return handling, SLA management, ...
    • Download Log from ASUSTOR NAS

      How to download Log from NAS Purpose: This article will helps support team to guide customer to download Log to share the evidence for component failure. Problem: Customer reports for Storage device not detected. Storage failure. / Storage not ...
    • Popular Articles

    • CP Plus Camera and NVR Configuration

      NVR Configuration The CP Plus Pro Series of NVRs have been meticulously designed for providing you with upgraded performance and higher recording quality in your IP video surveillance solution. The robust processor that has been inculcated in this ...
    • KB 775235 - Kerberos Authentication – Overview

      What is Kerberos? Kerberos is a secure authentication method used in our Active Directory (AD) environment (mbuzztech.com). It allows users to: Access multiple systems without re-entering passwords (Single Sign-On – SSO) Log in once Where We Use It ...
    • KB 935001 - AMD Ryzen AM4 Motherboard CPU Compatibility

      For the AM4 Platform, AMD has been very generous when it comes to motherboard compatibility. A CPU launched in 2022, like the Ryzen 7 5800X3D, will work with an almost 6-year-old motherboard, like the ASRock X370 Pro, which was launched in early ...
    • KB 532001 - Ubuntu Server 22.04 Installation Hangs on ASUS WRX80e-SAGE Series

      During the installation of Ubuntu Server 22.04 on ASUS WRX80E-SAGE series motherboards, the installation process hangs during the boot phase. The issue is associated with USB disk recognition errors, particularly with devices managed by the XHCI ...
    • KB 686001 - ASUS Server Stress Testing Guide for INTEL and AMD Platforms

      Creating a Bootable USB with Asus Test Tool Step 1: Download Required Files Download Asus Linux Image: Save the Linux image file provided by Asus. Download Memtest Tool: Open a browser, search for "Memtest," and download the free version from the ...