Setting up a PXE BOOT server in Fedora/CentOS:
PXE is an acronym meaning Preboot eXecution Environment and is pronounced "pixie". It allows you to boot a computer from the network as though it were a boot disk. If you're like me, you install Fedora/CentOS on people's computers all the time and burning new boot disks becomes an enviromental hazard. This solution is brilliant for saving the earth one DVD at a time.
Read more here:
http://en.wikipedia.org/wiki/Preboot_Execution_Environment
Make sure you've become root for all installations and configurations:
su |
Install/Configure DHCP Server:
DHCP means Dynamic Host Configuration Protocol and is used to hand out IP addresses
Set the static IP Address of the DHCP server
vi /etc/sysconfig/network-scripts/ifcfg-enp1s0 |
/etc/sysconfig/network-scripts/ifcfg-enp1s0 should look something like this:
HWADDR="XX:XX:XX:XX:XX:XX" # this is set to whatever your MAC address is TYPE="Ethernet" BOOTPROTO="static" DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_FAILURE_FATAL="no" NAME="enp1s0" UUID="c43c54f8-1850-496a-8833-19919d5de78e" ONBOOT="yes" IPADDR="192.168.1.254" PREFIX="24" GATEWAY="192.168.1.1" DNS1="192.168.1.1" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" |
Restart the network service
systemctl restart network.service |
Install the DHCP server
yum install dhcp |
Edit /etc/dhcp/dhcpd.conf
vi /etc/dhcp/dhcpd.conf |
/etc/dhcp/dhcpd.conf should look something like this:
# # Use this to enble / disable dynamic dns updates globally. # If this DHCP server is the official DHCP server for the local subnet 192.168.1.0 netmask 255.255.255.0 { # Default subnet mask to be used by DHCP clients # Default broadcast address to be used by DHCP clients # Default gateway to be used by DHCP clients # Change this to whatever you call your network # Default DNS to be used by DHCP clients # Range of IP addresses to be issued to DHCP clients # Amount of time in seconds that a client may keep the IP address # 86400 is 24h, set to less if you have a lot of DHCP clients # Eastern Standard Time # Default NTP server to be used by DHCP clients # These two options tell clients where to go to get the file needed to start the boot process. next-server 192.168.1.254; # Fixed IP addresses can also be specified for hosts. These addresses host fantasia { } |
Enable and start DHCP server
systemctl enable dhcpd.service |
Open the DHCP port on the firewall and make it permanent
firewall-cmd --add-service=dhcp --permanent |
Add your DNS servers to resolv.conf
vi /etc/resolv.conf |
/etc/resolv.conf should look something like this:
nameserver 192.168.1.1 |
To view the dhcp clients list
view /var/lib/dhcpd/dhcpd.leases |
Install/Configure TFTP Server
Trivial File Transfer Protocol is used for PXE booting because of its simplicity.
Install the TFTP server
yum install tftp-server |
Edit /etc/xinetd.d/tftp and set disable to no
vi /etc/xinetd.d/tftp |
/etc/xinetd.d/tftp should look like this
service tftp |
Open TFTP port on firewall and make it permanant
firewall-cmd --add-service=tftp --permanent |
Install/Configure FTP Server
File Transfer Protocol is used to hold and transfer the disk images. We will use vsftpd for this, which stands for "Very Secure FTP Daemon". It is supposed to be the most secure and fastest of the FTP servers. I haven't tested this personally... but whatever.
Install FTP server
yum install vsftpd |
Edit /etc/vsftpd/vsftpd.conf
vi /etc/vsftpd/vsftpd.conf |
/etc/vsftpd/vsftpd.conf shouldn't need any editing, but check anyway
anonymous_enable=YES |
Download the distro iso files, mount and copy them to your FTP server
I will be using CentOS and Fedora, but you can use whichever distros you want.
CentOS 7 x86_64
mkdir -p /mnt/iso |
Fedora 20 x86_64
mkdir -p /mnt/iso |
Fedora 20 i386
mkdir -p /mnt/iso |
Enable and start the VSFTP server
systemctl enable vsftpd.service |
Open the FTP port on the firewall and make it permanent
firewall-cmd --add-service=ftp --permanent |
Install/Configure PXE Boot Service
Install the syslinux package which contains the files we need for the PXE server.
yum install syslinux |
Copy the PXE boot loader to the TFTP root directory
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ |
CentOS 7 x86_64
mkdir -p /var/lib/tftpboot/images/centos/x86_64/7 |
Fedora 20 x86_64
mkdir -p /var/lib/tftpboot/images/fedora/x86_64/20 |
Fedora 20 i386
mkdir -p /var/lib/tftpboot/images/fedora/i386/20 |
Copy boot menu and graphic to the TFTP boot root folder
cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/ |
You can get centos7pxebg.png from here: centos7pxebg.png
Configure PXE Boot Menu
Create /tftpboot/pxelinux.cnf directory
mkdir -p /var/lib/tftpboot/pxelinux.cfg |
Create /var/lib/tftpboot/pxelinux.cfg/default configuration file
vi /var/lib/tftpboot/pxelinux.cfg/default |
default should look something like this
DEFAULT vesamenu.c32 #Local Boot #CentOS 7 x86_64 # ks=ftp://192.168.1.254/install/centos/x86_64/7/ks/ks.cfg # add this to APPEND if you have a kickstart file #Fedora 20 x86_64 # ks=ftp://192.168.1.254/install/fedora/x86_64/20/ks/ks.cfg # add this to APPEND if you have a kickstart file #Fedora 20 i386 |
(Optional) Automating installations using kickstart
Install kickstart
yum install system-config-kickstart |
Create kickstart file and place copy it to your ftp site
mkdir /var/ftp/install/centos/x86_64/7/ks |
Following is my kickstart configuration file that have been placed in /var/ftp/install/centos/x86_64/7/ks
#platform=x86, AMD64, or Intel EM64T # System bootloader configuration %packages %end |