CentOSRHEL Based

How To Configure PXE Boot Server on CentOS Stream 9

Configure PXE Boot Server on CentOS Stream 9

PXE (Preboot Execution Environment) is a powerful tool for network administrators, enabling them to install operating systems and boot computers over a network. This technology eliminates the need for physical installation media, making the deployment process more efficient and streamlined. In this article, we will focus on configuring a PXE boot server on CentOS Stream 9, a stable and reliable Linux distribution that is well-suited for server environments. By the end of this guide, you will have a fully functional PXE boot server capable of installing CentOS Stream 9 on client machines across your network.

Prerequisites

Before we dive into the configuration process, ensure that you have the following prerequisites in place:

  • A CentOS Stream 9 server with a static IP address
  • Sufficient storage space for the CentOS Stream 9 installation files
  • A basic understanding of Linux command line and network configuration

Step 1: Install and Configure DHCP Server

The Dynamic Host Configuration Protocol (DHCP) server plays a crucial role in PXE booting by assigning IP addresses to client machines and directing them to the PXE boot files. To install the DHCP server on your CentOS Stream 9 machine, run the following command:

sudo dnf install dhcp-server

Once installed, configure the DHCP server by editing the /etc/dhcp/dhcpd.conf file. Add the following lines to set up the IP range and specify the PXE boot file:

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option routers 192.168.1.1;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
  filename "pxelinux.0";
  next-server 192.168.1.10;
}

Replace the IP addresses and ranges with values appropriate for your network. The filename option specifies the PXE boot file, while next-server points to the IP address of your PXE boot server.

Step 2: Install and Configure TFTP Server

The Trivial File Transfer Protocol (TFTP) server is responsible for serving the boot files to client machines during the PXE boot process. Install the TFTP server on your CentOS Stream 9 machine using the following command:

sudo dnf install tftp-server

Configure the TFTP server by editing the /etc/xinetd.d/tftp file. Ensure that the disable option is set to no and the server_args option points to the correct TFTP directory:

service tftp
{
  socket_type = dgram
  protocol = udp
  wait = yes
  user = root
  server = /usr/sbin/in.tftpd
  server_args = -s /var/lib/tftpboot
  disable = no
  per_source = 11
  cps = 100 2
  flags = IPv4
}

Additionally, configure the firewall to allow TFTP traffic by running:

sudo firewall-cmd --add-service=tftp --permanent
sudo firewall-cmd --reload

Step 3: Prepare the PXE Boot Environment

To set up the PXE boot environment, install the necessary bootloader packages, such as Syslinux or GRUB2. In this example, we will use Syslinux:

sudo dnf install syslinux

Copy the required boot files to the TFTP directory:

sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
sudo cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
sudo cp /usr/share/syslinux/memdisk /var/lib/tftpboot/
sudo cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot/
sudo cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot/

Create directories for the CentOS Stream 9 installation files and copy the necessary files from the ISO image:

sudo mkdir -p /var/lib/tftpboot/centos9/
sudo mount -o loop /path/to/CentOS-Stream-9-x86_64-dvd.iso /mnt/
sudo cp -r /mnt/* /var/lib/tftpboot/centos9/
sudo umount /mnt

Step 4: Configure the PXE Boot Menu

The PXE boot menu allows users to select the desired boot option during the network boot process. To configure the menu, create a directory for the configuration files:

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

Create a default configuration file named default in the pxelinux.cfg directory with the following content:

default menu.c32
prompt 0
timeout 30
 
menu title PXE Boot Menu
 
label centos9
  menu label Install CentOS Stream 9
  kernel centos9/images/pxeboot/vmlinuz
  append initrd=centos9/images/pxeboot/initrd.img inst.repo=http://192.168.1.10/centos9
 
label local
  menu label Boot from local disk
  localboot 0

Adjust the inst.repo URL to point to the IP address of your PXE boot server.

Step 5: Set Up HTTP Server for Installation Files

To serve the CentOS Stream 9 installation files to client machines, set up an HTTP server on your PXE boot server. Install Apache HTTP Server using the following command:

sudo dnf install httpd

Create a directory to store the installation files and copy the contents of the CentOS Stream 9 ISO:

sudo mkdir -p /var/www/html/centos9
sudo cp -r /path/to/CentOS-Stream-9-x86_64-dvd.iso/* /var/www/html/centos9/

Start the Apache HTTP Server and enable it to start at boot:

sudo systemctl start httpd
sudo systemctl enable httpd

Step 6: Testing the PXE Boot Server

With the PXE boot server configuration complete, it’s time to test the setup. Boot a client machine on the same network and ensure that it obtains an IP address from the DHCP server. The client should then display the PXE boot menu, allowing you to select the CentOS Stream 9 installation option.

If you encounter any issues during the PXE boot process, consider the following troubleshooting tips:

  • Verify that the client machine’s BIOS or UEFI settings are configured to boot from the network.
  • Check the network connectivity between the client and the PXE boot server.
  • Ensure that the DHCP, TFTP, and HTTP services are running and properly configured on the PXE boot server.
  • Review the PXE boot server logs for any error messages or warnings.

Conclusion

Configuring a PXE boot server on CentOS Stream 9 is a straightforward process that can greatly simplify the deployment of operating systems across a network. By following the steps outlined in this article, you can set up a reliable and efficient PXE boot environment, enabling you to install CentOS Stream 9 on multiple machines without the need for physical installation media. With a properly configured PXE boot server, you can save time, reduce manual effort, and streamline your network installation workflows.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button