How to Set Up a Multi-PXE Installation Server
How to Set Up a Multi-PXE Installation Server
Setting up a multi-PXE (Preboot Execution Environment) installation server is an efficient way to manage the deployment of multiple operating systems across a network. PXE allows you to boot and install operating systems on client machines without the need for physical media like USB drives or DVDs. By configuring a multi-PXE server, you can provide access to various operating system images (like Linux distributions, Windows, or recovery tools) for network-based installations. In this guide, we will walk through the process of setting up a multi-PXE installation server on a Linux-based machine.
Prerequisites
Before starting, ensure the following prerequisites are in place:
A dedicated Linux server to act as the PXE server (Ubuntu, Debian, or CentOS are common choices).
Network access for both the server and client machines.
DHCP and TFTP services installed and configured.
ISO images or installation files for the operating systems you wish to deploy.
Basic knowledge of Linux command-line operations.
Step 1: Installing Required Services
To set up a PXE server, several services are needed: TFTP for file transfers, DHCP for assigning IP addresses to clients, and optionally NFS or HTTP to serve OS installation files.
Install TFTP Server:
First, install the TFTP server package. On Ubuntu/Debian-based systems, run:
sudo apt update
sudo apt install tftpd-hpa
On CentOS/RHEL-based systems:
sudo yum install tftp-server
Once installed, you need to configure the TFTP service. Open the TFTP configuration file:
sudo nano /etc/default/tftpd-hpa
Modify the settings as follows:
TFTP_DIRECTORY=”/var/lib/tftpboot”
TFTP_OPTIONS=”–secure”
Save and close the file, then restart the TFTP service:
sudo systemctl restart tftpd-hpa
Install DHCP Server:
You’ll also need a DHCP server to assign IP addresses to the client machines. On Ubuntu/Debian systems:
sudo apt install isc-dhcp-server
On CentOS:
sudo yum install dhcp-server
After installing the DHCP server, configure it to work with your PXE setup. Open the DHCP configuration file:
sudo nano /etc/dhcp/dhcpd.conf
Add or modify the following settings to match your network environment:
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 broadcast-address 192.168.1.255;
filename “pxelinux.0”;
next-server 192.168.1.10; # PXE Server IP
}
Adjust the IP ranges and network configuration according to your environment. Save the file and restart the DHCP service:
sudo systemctl restart isc-dhcp-server
Install SYSLINUX:
SYSLINUX provides the PXE bootloader needed for booting various operating system images. Install SYSLINUX with the following command:
sudo apt install syslinux pxelinux
After installation, copy the pxelinux.0 file to your TFTP directory:
sudo cp /usr/lib/PXELINUX/pxelinux.0 /var/lib/tftpboot/
Step 2: Setting Up the TFTP Directory
The TFTP directory is where the boot files and configuration files will reside. Organize the directory structure under /var/lib/tftpboot as follows:
sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg
sudo mkdir /var/lib/tftpboot/images
The pxelinux.cfg directory contains the boot menu configuration, and the images directory will store the operating system boot files.
Step 3: Configuring the PXE Boot Menu
Next, configure the boot menu, which allows clients to select which operating system to install. Create a default configuration file for PXE:
sudo nano /var/lib/tftpboot/pxelinux.cfg/default
Add the following content:
DEFAULT menu.c32
PROMPT 0
MENU TITLE PXE Boot Menu
TIMEOUT 600
LABEL ubuntu
MENU LABEL Install Ubuntu
KERNEL images/ubuntu/vmlinuz
APPEND initrd=images/ubuntu/initrd.gz
LABEL centos
MENU LABEL Install CentOS
KERNEL images/centos/vmlinuz
APPEND initrd=images/centos/initrd.gz
In this example, we have two menu options: one for installing Ubuntu and one for CentOS. Adjust the kernel and initrd paths based on your OS images.
Step 4: Adding OS Installation Files
Now, add the operating system boot files to the TFTP directory.
For Ubuntu:
Download the kernel and initrd files from an official Ubuntu mirror or extract them from an ISO image. Place them in the /var/lib/tftpboot/images/ubuntu directory:
sudo mkdir -p /var/lib/tftpboot/images/ubuntu
sudo cp /path/to/vmlinuz /var/lib/tftpboot/images/ubuntu/
sudo cp /path/to/initrd.gz /var/lib/tftpboot/images/ubuntu/
For CentOS:
Similarly, download or extract the CentOS kernel and initrd files and place them in the /var/lib/tftpboot/images/centos directory:
sudo mkdir -p /var/lib/tftpboot/images/centos
sudo cp /path/to/vmlinuz /var/lib/tftpboot/images/centos/
sudo cp /path/to/initrd.img /var/lib/tftpboot/images/centos/
Repeat this process for any additional operating systems you want to serve.
Step 5: Setting Up HTTP or NFS for OS Installation Files
TFTP is used to deliver the initial boot files, but the full OS installation files (ISO or packages) can be served via HTTP or NFS. Install an HTTP server like Apache:
sudo apt install apache2
Once installed, place the full OS installation images in the web root:
sudo cp -r /path/to/ubuntu/installation/files /var/www/html/ubuntu
sudo cp -r /path/to/centos/installation/files /var/www/html/centos
You can then modify the PXE boot menu’s APPEND line to reference the HTTP paths for the installation media:
APPEND initrd=images/ubuntu/initrd.gz boot=casper netboot=nfs nfsroot=192.168.1.10:/var/www/html/ubuntu
Step 6: Booting Clients via PXE
Once everything is configured, ensure that your network is set up to boot from the PXE server. Adjust the BIOS/UEFI settings on the client machines to boot from the network (PXE boot). When the client machine starts, it will receive an IP from the DHCP server and pull the PXE boot menu from the TFTP server.
Once the boot menu appears, the user can select the desired operating system, and the installation process will begin over the network.
By following these steps, you will have a multi-PXE installation server capable of deploying various operating systems to multiple clients across your network.
If you want, you can also read our article about cobbler 🙂
How to Install Cobbler on Alpine Linux Latest
You can also try these packages in a reliable environment by renting a server from our site.