Home‎ > ‎unix/linux‎ > ‎Centos Systems‎ > ‎

PXE/Jumpstart server

Overview

To get a pxe server working, you will need to get the following installed and working: 
  • DHCP server
  • TFTP Server
  • NFS/FTP/HTTPd server so that you can store the instal files

Install

install needed packages

[root@mon01 ~]# yum install dhcp tftp tftp-server syslinux wget vsftpd


Configure DHCP Server

STOP!
OK... first.  Remember that your installing a DHCP server here.  You need to make sure that the network that your building this server does NOT already have a DHCP server, or things are going to get messy quick.  Once you've got that cleared up, you can safely continue. 

first edit the dhcp server config file
vim /etc/dhcp/dhcpd.conf

and add the following changes.  Notice the IP ranges that I've set.  My network is 198.18.3.0/24, with dns = 198.18.3.200
You will need to modify to match your network.  
 
# option definitions common to all supported networks...
ddns-update-style interim;
ignore client-updates;
authoritative;
allow booting;
allow bootp;
allow unknown-clients;

# A slightly different configuration for an internal subnet.
subnet 198.18.3.0 netmask 255.255.255.0 {
  range 198.18.3.210 198.18.3.230;
  option domain-name-servers 198.18.3.200;
  option domain-name "cmed.us";
  option routers 198.18.3.1;
  option broadcast-address 198.18.3.255; # not important
  default-lease-time 600;
  max-lease-time 7200;
 
  # PXE SERVER IP
  next-server 198.18.3.200; # DHCP server ip
  filename "pxelinux.0";
}

Define what interface is listening by editing the following file
cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/
vim /etc/systemd/system/dhcpd.service

and making this change
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid enp0s3

Configure TFTP Server

Modify the config file

edit the following file
vim /etc/xinetd.d/tftp

and modify it so that the variables are equal to the following
service tftp
 {
   socket_type             = dgram
   protocol                = udp
   wait                    = yes
   user                    = root
   server                  = /usr/sbin/in.tftpd
   server_args             = -s /tftpboot
   disable                 = no
   per_source              = 11
   cps                     = 100 2
   flags                   = IPv4
 }

Setup network boot files

create the tftpboot directory
mkdir -p /tftpboot
chmod 777 /tftpboot
mkdir /tftpboot/pxelinux.cfg
mkdir -p /tftpboot/netboot/

and then copy the needed files into it
cp -v /usr/share/syslinux/pxelinux.0 /tftpboot
cp -v /usr/share/syslinux/menu.c32 /tftpboot
cp -v /usr/share/syslinux/memdisk /tftpboot
cp -v /usr/share/syslinux/mboot.c32 /tftpboot
cp -v /usr/share/syslinux/chain.c32 /tftpboot

Get the iso you want to present to hosts
curl http://mirrors.greenmountainaccess.net/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso --output CentOS-7-x86_64-Minimal-1708.iso

present an ISO to boot from.  In this case, we're having new hosts boot from the 
mount the centos iso, and copy its contents
[root]# mkdir -p /var/ftp/pub2
[root]# mount CentOS-7-x86_64-Minimal-1708.iso /var/ftp/pub2
mount: /dev/loop0 is write-protected, mounting read-only

copy the contents of the iso elsewhere so we can modify it. 
mkdir /var/ftp/pub
rsync --progress -av /var/ftp/pub2 /var/ftp
mv /var/ftp/pub2 /var/ftp/pub

unmount the iso
[root@mon01 ~]# umount CentOS-7-x86_64-Minimal-1708.iso
[root@mon01 ~]#

copy these files to the tftpboot mount
cp /var/ftp/pub/images/pxeboot/vmlinuz /tftpboot/netboot/
cp /var/ftp/pub/images/pxeboot/initrd.img /tftpboot/netboot/

Create the kickstart file

first choose a root password (like letmein) and make a password hash for it 
[root]# openssl passwd -1 "letmein"
$1$Gl87LpfV$YZ454yuxd.nKCf7Sk.KGs1
[root]#

Create the kickstart file 
vim /var/ftp/pub/ks.cfg

and take the yellow highlighted part from above (the password hash), and paste it in here (see highlighted).  Also, make sure that you modify the red highlighted part with your hosts IP address.  
# platform=x86, AMD64, or Intel EM64T
# version=DEVEL
# Firewall configuration
firewall --disabled

# Install OS instead of upgrade
install

# Use NFS installation media
url --url="ftp://199.18.3.200/pub/"

# Root password [from above]
rootpw --iscrypted $1$Gl87LpfV$YZ454yuxd.nKCf7Sk.KGs1

# System authorization information
auth  useshadow  passalgo=sha512

# Use graphical install
graphical
firstboot disable

# System keyboard
keyboard us

# System language
lang en_US

# SELinux configuration
selinux disabled

# Installation logging level
logging level=info

# System timezone
timezone America/New_York

# System bootloader configuration
bootloader location=mbr
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=200
part pv.01 --size=1 --grow
volgroup rootvg01 pv.01
logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow

%packages
 @core
 wget
 net-tools
 %end
 %post
 %end

Create the PXE menu file

create the PXE file
vim /tftpboot/pxelinux.cfg/default

and add the following to it, while renaming the highlighted to the servers IP.  
default menu.c32
prompt 0
timeout 30
MENU TITLE unixme.com PXE Menu

LABEL centos7_x64
MENU LABEL CentOS 7 X64
KERNEL /netboot/vmlinuz
APPEND  initrd=/netboot/initrd.img  inst.repo=ftp://198.18.3.200/pub  ks=ftp://198.18.3.200/pub/ks.cfg


Final Steps


chkconfig dhcpd on
chkconfig xinetd on
chkconfig vsftpd on


service vsftpd restart
service dhcpd restart
service xinetd restart


References: 

Comments