Build PXE server and KickStart
User Rating: / 4
PoorBest 

Let’s try and get this server running. First thing to do is get the rpms. You can either use yum or try and find the rpms yourself.
First things first, PXE is the short for Preboot Execution Environment. This will allow you to boot using the OS installation from the Network.
This is definitely something to have in a large enterprise, when several OS deployments occur with similar configurations. For home users it's more like a way to learn a bit more about PXE. 

What you’ll need:
-    Xinetd to  tftp-server enabled
-    ftp server, I use vsftpd
-    dhcp configured to allow bootp.
-    A CentOS or RedHat DVD iso, depending in what you want to Kickstart or boot from the Network.



1st Step – Get the Rpms
#yum install xinetd dhcp tftp-server vsftpd system-config-kickstart

2nd Step – Get DHCP configured.
I’m using DHCP for my home network, so I’ve added the lines to allow unknown clients, booting, bootp and the linux with the filename to look for “pxelinux.0".
I’ve fixed leases for my all MAC addresses but I’ll paste only an example for reference:

Contents of /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
option domain-name "DOMINIO";
allow unknown-clients;
allow booting;
allow bootp;
filename "pxelinux.0";

subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.2;
        option subnet-mask              255.255.255.0;
        option domain-name-servers 194.72.0.114, 62.6.40.162;
        option broadcast-address        192.168.1.255;

        default-lease-time 3100;
        max-lease-time 604800;

        host MyNewCentOS {
                hardware ethernet 00:4F:61:40:18:38;
                fixed-address 192.168.1.3;
        }


3rd Step – Get tftp working through xinetd
TFTP uses UDP. Since it a simple form of FTP, it uses port 69 UDP with no security, make sure you don’t open your firewall to the world… 

Edit the file /etc/xinetd.d/tftp and change the line that says “disable = yes” to “disable = no “.
If left by default the root for the tftp server will be /tftpboot
I will wait until the end to restart it, since it won’t make a difference having it working at this point.
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
}

4th Step – Prepare the FTP access and Mount the ISO.
For ftp access to the ISOs create the installation directories under /var/ftp. By default user “anonymous” will have access. Make sure your firewall is open for your lan and closed to the rest of the world.  I will use a Centos 5.2 install DVD iso that I’ve in my server.

#mkdir –p /var/ftp/install/CentOS5x64
#mount –t iso9660 -o loop  /export/software/os/CentOS/CentOS-5.2-x86_64-bin-DVD.iso /var/ftp/install/CentOS5x64

5th Step – copy the boot files to /tftpboot directory to be able to boot.

#cp /usr/share/syslinux/pxelinux.0 /tftpboot/
#mkdir –p /tftpboot/images/CentOS5x64
#cp /var/ftp/install/CentOS5x64/images/pxeboot/vmlinuz /tftpboot/images/CentOS5x64/
#cp /var/ftp/install/CentOS5x64/images/pxeboot/initrd /tftpboot/images/CentOS5x64/

6th Step Configure the KickStart Configuration file:
The Kickstart config file will have the answers for an unattended installation of CentOS . I will be placing that file in /var/ftp/install/ks/CentOS5x64.cfg directory.

Get a X capable terminal and executed the configuration Gui:
# system-config-kickstart
A Gui will pop up, make sure you configure all needed parameters. Don’t forget to specify the ftp server IP and the location of the installation. Remember the installation will be using the user anonymous to connect to the ftp server and the root of the ftp server is /var/ftp.

Once you’ve created a Kickstart configuration file save it and place it in /var/ftp/install/ks/CentOS5x64.cfg.


7th Step – Create a PXE menu and a default configuration
#cp /usr/share/syslinux/menu.c32 /tftpboot
#mkdir /tftpboot/pxelinux.cfg

Edit a new file called /tftpboot/pxelinux.cfg/default and add the following contents:
default menu.c32
prompt 0
timeout 300
MENU TITLE My PXE Menu
LABEL CentoS 5.2 x64
MENU LABEL CentOS 5.2 x64
KERNEL images/CentOS5x64/vmlinuz
append vga=normal initrd= images/CentOS5x64/initrd.img ramdisk_size=32768 method=ftp:///install/CentOS5x64 ks=>/install/ks/CentOS5x64.cfg

8th Step – Restart all services and try and boot from the Network.
# service xinetd restart;
# service dhcpd restart;
# service vsftpd restart;

Note: I’ve used a Vmware setup to test it.

Below a sample ks.cfg file:

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --linux
# Use text mode install
text
# Firewall configuration
firewall --enabled   --trust=eth0
# Run the Setup Agent on first boot
firstboot --disable
key teste
# System keyboard
keyboard pt-latin1
# System language
lang en_US
# Installation logging level
logging --level=info
# Use network installation
url --url=ftp://192.168.6.1/install/CentOS5x64
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw  $1$dMjkOF$nxawIlTE/wJUZK0

# SELinux configuration
selinux --disabled
# System timezone
timezone  Europe/Lisbon
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig  --defaultdesktop=GNOME --depth=32 --resolution=1024x768
# Disk partitioning information
part / --bytes-per-inode=4096 --fstype="ext3" --size=7000
part swap --bytes-per-inode=4096 --fstype="swap" --size=500

%packages
@base
@smb-server

 
Main Menu
Profile
MaTaPorKoZ 2009