In this article, I am going to show you how to setup a PXE boot server on CentOS 7 and configure it to boot Fedora 30 Workstation Live installer over the network via PXE. So, let’s get started.
Here, I will configure a CentOS 7 server as a PXE boot server. The PXE boot server will serve Fedora 30 Workstation Live installation media to the PXE clients. Then, I will install Fedora 30 Workstation on the PXE client over the network. The PXE boot server will have a fixed IP 192.168.50.1. The PXE client will be on the same network.
Configuring the Network:
You can use nmtui to configure a static IP to the network interface on your CentOS 7 machine. To learn how to do that, you may read a dedicated article on this topic at https://linuxhint.com/setup_static_ip_centos7/
Here, I used ens37 for configuring PXE boot server. Change it depending on your setup.
Installing and Configuring DHCP and TFTP for PXE Boot:
You have to configure a DHCP and a TFTP server for PXE boot. I will use dnsmasq for that.
First, update the YUM package repository cache with the following command:
Now, install the dnsmasq with the following command:
dnsmasq should be installed.
Now, rename the original /etc/dnsmasq.conf file to /etc/dnsmasq.conf.backup as follows:
Now, create an empty dnsmasq.conf file with the following command:
Now, type in the following lines to the file:
pxe-prompt="Press F8 for PXE Network boot.", 5
pxe-service=x86PC, "Install OS via PXE",pxelinux
The final configuration file should look as follows. Once you’re done, save the configuration file.
Now, create a new directory /netboot/tftp for TFTP as follows:
Now, restart the dnsmasq service with the following command:
NOTE: I set SELinux to permissive mode on my CentOS 7 machine. Because, if SELinux is set to enforcing mode, dnsmasq won’t start in this configuration. Covering SELinux is out of the scope of this article.
Now, check whether the dnsmasq service is running or not with the following command:
As you can see, dnsmasq service is running.
Now, add the dnsmasq service to the system startup as follows:
Installing and Configuring PXE Bootloader:
Now, you have to install the PXE bootloader files and copy them over to the TFTP root directory.
To install the PXE bootloader files, run the following command:
Once syslinux is installed, copy the pxelinux.0 and menu.c32 files to the /netboot/tftp directory as follows:
Now, create PXE bootloader configuration directory /netboot/tftp/pxelinux.cfg/ as follows:
Now, create PXE bootloader’s default configuration file /netboot/tftp/pxelinux.cfg/default as follows:
TFTP server is now able to serve all the required bootloader files over the network.
Installing Apache Web Server:
Fedora 30 Workstation uses Dracut as the kernel command line option provider. It supports PXE booting over HTTP. So, I am going to use the Apache 2 web server to serve the Fedora 30 Workstation files over the network.
To install Apache 2 web server, run the following command:
Apache 2 should be installed.
Now, make a symbolic link /netboot/www of the /var/www/html directory for easier management of the PXE boot server as follows:
The symbolic link should be created.
Now, start the httpd service as follows:
Now, check whether the httpd service is running as follows:
As you can see, the httpd service is running correctly.
Now, add the httpd service to the system startup with the following command:
Preparing Fedora 30 Workstation for PXE Boot:
Now, download the Fedora 30 Workstation Live ISO image with the following command:
It will take a while for the download to complete.
Now, mount the Fedora 30 Workstation Live ISO image on the /mnt directory as follows:
Now, create dedicated directories for Fedora 30 Workstation /netboot/www/fedora30/ and /netboot/tftp/fedora30/ as follows:
Now, copy the contents of the ISO file to the /netboot/www/fedora30/ directory as follows:
The contents of the Fedora 30 Workstation ISO file should be copied.
Now, copy the initrd.img and vmlinuz files of Fedora 30 Workstation to the /netboot/tftp/fedora30/ directory as follows:
Now, you can unmount the Fedora 30 Workstation ISO image and delete it if you want.
$ rm Fedora-Workstation-Live-x86_64-30-1.2.iso
Adding PXE Boot Entry for Fedora 30 Workstation:
Now, you have to add a boot entry for Fedora 30 Workstation on the /netboot/tftp/pxelinux.cfg/default file.
Open the PXE boot menu configuration file /netboot/tftp/pxelinux.cfg/default for editing as follows:
Now, add the following lines to the file.
menu label ^Install Fedora 30 Workstation
append initrd=fedora30/initrd.img root=live:http://192.168.50.1/fedora30/
LiveOS/squashfs.img plymouth.enable=1 rd.live.image rd.luks=0 rd.md=0
The final configuration file should look as follows. Once you’re done, save the file.
Adding Firewall Rules:
Now, you have to open ports from your firewall for the PXE boot server to work.
Allow the DHCP service as follows:
Allow the HTTP service as follows:
Allow the TFTP service as follows:
Allow the UDP port 4011 and 69 as follows:
Now, reload the firewall as follows:
Installing Fedora 30 Workstation via PXE:
Now, on the PXE client where you want to install Ubuntu 18.04 LTS over the network via PXE, go to the BIOS and select Network Boot.
When you see the following message, press <F8> on your keyboard.
Now, select Install OS via PXE and press <Enter>.
You will only have one option. So, just press <Enter>.
Fedora 30 Workstation Live installer should start.
Now, you can install it on your client machine as usual.
So, that’s how you configure PXE boot server on CentOS 7. Thanks for reading this article.