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

pxebootscreen

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:

#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#

# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

subnet 192.168.1.0 netmask 255.255.255.0 {

       # Default subnet mask to be used by DHCP clients
       option subnet-mask                     255.255.255.0;

       # Default broadcast address to be used by DHCP clients
       option broadcast-address           192.168.1.255;

       # Default gateway to be used by DHCP clients
       option routers                             192.168.1.1;

       # Change this to whatever you call your network
       option domain-name                  "geekface.ca";

       # Default DNS to be used by DHCP clients
       option domain-name-servers      192.168.1.1;

       # Range of IP addresses to be issued to DHCP clients
       range                                           192.168.1.100 192.168.1.200;

       # Amount of time in seconds that a client may keep the IP address
       default-lease-time                         86400;

       # 86400 is 24h, set to less if you have a lot of DHCP clients
       max-lease-time                             86400;

       # Eastern Standard Time
       option time-offset                         -18000;

       # Default NTP server to be used by DHCP clients
#       option ntp-servers                      192.168.1.1;

# These two options tell clients where to go to get the file needed to start the boot process.

        next-server                                 192.168.1.254;
        filename                                      "pxelinux.0";

# Fixed IP addresses can also be specified for hosts.   These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.

        host fantasia {
                hardware ethernet      08:00:07:26:c0:a5;
                fixed-address               192.168.1.10;
                option host-name        "fantasia.example.com";
        }

}

 

Enable and start DHCP server

systemctl enable dhcpd.service
systemctl start 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
{
        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
}

 

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
anon_root=/var/lib/tftpboot/

 

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
mkdir -p /var/ftp/install/centos/x86_64/7
mount -t iso9660 -o loop CentOS-7.0-1406-x86_64-DVD.iso /mnt/iso
cp -avr /mnt/iso/* /var/ftp/install/centos/x86_64/7

 

Fedora 20 x86_64

mkdir -p /mnt/iso
mkdir -p /var/ftp/install/fedora/x86_64/20
mount -t iso9660 -o loop Fedora-20-x86_64-DVD.iso /mnt/iso
cp -avr /mnt/iso/* /var/ftp/install/fedora/x86_64/20

 

Fedora 20 i386

mkdir -p /mnt/iso
mkdir -p /var/ftp/install/fedora/i386/20
mount -t iso9660 -o loop Fedora-20-i386-DVD.iso /mnt/iso
cp -avr /mnt/iso/* /var/ftp/install/fedora/i386/20

 

Enable and start the VSFTP server

systemctl enable vsftpd.service
systemctl start 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
cp /var/ftp/install/centos/x86_64/7/images/pxeboot/initrd.img /var/lib/tftpboot/images/centos/x86_64/7
cp /var/ftp/install/centos/x86_64/7/images/pxeboot/upgrade.img /var/lib/tftpboot/images/centos/x86_64/7
cp /var/ftp/install/centos/x86_64/7/images/pxeboot/vmlinuz /var/lib/tftpboot/images/centos/x86_64/7

 

Fedora 20 x86_64

mkdir -p /var/lib/tftpboot/images/fedora/x86_64/20
cp /var/ftp/install/fedora/x86_64/20/images/pxeboot/initrd.img /var/lib/tftpboot/images/fedora/x86_64/20
cp /var/ftp/install/fedora/x86_64/20/images/pxeboot/upgrade.img /var/lib/tftpboot/images/fedora/x86_64/20
cp /var/ftp/install/fedora/x86_64/20/images/pxeboot/vmlinuz /var/lib/tftpboot/images/fedora/x86_64/20

 

Fedora 20 i386

mkdir -p /var/lib/tftpboot/images/fedora/i386/20
cp /var/ftp/install/fedora/i386/20/images/pxeboot/initrd.img /var/lib/tftpboot/images/fedora/i386/20
cp /var/ftp/install/fedora/i386/20/images/pxeboot/upgrade.img /var/lib/tftpboot/images/fedora/i386/20
cp /var/ftp/install/fedora/i386/20/images/pxeboot/vmlinuz /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/
cp centos7pxebg.png /var/lib/tftpboot/

You can get centos7pxebg.png from here: centos7pxebg.png

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
MENU BACKGROUND centos7pxebg.png
MENU COLOR BORDER 0 #ffffffff #00000000 std
MENU COLOR TITLE 0 #ffffffff #00000000 std
MENU COLOR SEL 0 #ffffffff #ff000000 std
MENU TITLE CentOS 7 PXE Boot Menu
PROMPT 0
TIMEOUT 300
ONTIMEOUT local

#Local Boot
LABEL local
MENU LABEL Boot Local HDD
LOCALBOOT 0

#CentOS 7 x86_64
LABEL centos764
MENU LABEL CentOS 7 x86_64
KERNEL images/centos/x86_64/7/vmlinuz
APPEND initrd=images/centos/x86_64/7/initrd.img inst.repo=ftp://192.168.1.254/install/centos/x86_64/7

# 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
LABEL fedora2064
MENU LABEL Fedora 20 x86_64
KERNEL mages/fedora/x86_64/20/vmlinuz
APPEND initrd=images/fedora/x86_64/20/initrd.img inst.repo=ftp://192.168.1.254/install/fedora/x86_64/20

# 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
LABEL Fedora2032
MENU LABEL Fedora 20 i386
KERNEL images/fedora/i386/20/vmlinuz
APPEND initrd=images/fedora/i386/20/initrd.img inst.repo=ftp://192.168.1.254/install/fedora/i386/20



(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
cp ks.cfg /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
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'uk'
# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$S3yaP42N$4m33vWv0Is8QXdbbb7TKi/
# System timezone
timezone America/Toronto
# Use network installation
url --url="ftp://192.168.1.254/install/centos/x86_64/7"
# System language
lang en_CA
# Firewall configuration
firewall --enabled
# Network information
network --bootproto=dhcp --device=eth0
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --enforcing

# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel

%packages
@cinnamon-desktop
@firefox
@gnome-desktop
@gnome-games
@libreoffice

%end



Copyright ©  Geekface Computers & Service

The Fedora logo is a trademark of Red Hat inc.