Low Orbit Flux Logo 2 F

Linux Kickstart Installation and PXE Boot Guide

Linux Kickstart

These are my old kickstart instructions. I haven’t used these in years but the instructions should still be fine. You may want to tweak things for more recent OS versions. It would also be worth checking out Spacewalk and Cobbler. Both of these tools basically use the same underlying technologies. Here we basically show you how to create a Kickstart server from scratch. With modern tools like virtual machines and containers this isn’t always necessary but when you do need to setup physical hosts, this is still the type of solution to use.

WARNING - These instructions are old. This was originally done with CentOS 5. You will want something newer. We also haven’t tested these instructions for a while. You may need to tweak a few things besides just using a newer version of Linux before you will be able to get it working.

What is a Linux Kickstart Server?

Kickstart is a system for Linux onto servers (or desktops) over the network. It is primarily useful if you have a lot of machines that you want to boot up and install an OS on in parallel.

Setup

We’re going to assume that you are running a Red Hat based system like RHEL, CentOS, or Fedora. Also, if you have never done this before, make sure you aren’t using an important production machine to set this up. Use a lab box.

You can run the kickstart configuration utility like this. It will help you to generate a kickstart file.


system-config-kickstart

Setup a Repo

Make sure you mount your installation CD…. or ISO…. or just make sure to have all of these files in the right location. Even when I’m installing on a VM I’ll generally connect the ISO image so that it looks as though it were a physical CD.


mount /dev/cdrom /media

Clear out your existing repos and create a new one. You might what to think about how you will manage this more carefully but for the purposes of this guide just go along with this.


cd /etc/yum.repos.d/
rm -f *.repo

vi local.repo

Your new repo file ( local.repo ) will look like this:


[Local-Media]
name=CentOS-$releasever - Media
baseurl=file:///media/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

Clean up and show your repo list:


yum clean all
yum repolist

Setup Apache HTTPD

Packages will be served by HTTPD. We’re going to install Apache to support this:


yum install -y httpd
rpm -qa | grep httpd
chkconfig httpd on
chkconfig --list httpd

Copy your repo packages over to your web directory:


cd /var/www/html
mkdir -p pub/kickstart
cp -r /mnt/RHEL5.2_x64_disk1/Server /var/www/html/pub/
cp -r /mnt/RHEL5.2_x64_disk1/images /var/www/html/pub/

Kickstart Config and Password

Generate a password. Just run this command and enter a password to generate a hash. You will need this for your config. Don’t forget the password. If you do forget, no big deal, just change it and rebuild any severs you built using it.


 openssl passwd -1      

Copy the sample file to create a new kickstart file:


cd pub/kickstart
cp sample.cfg my-kickstart.cfg
vi my-kickstart.cfg

Add an encrypted root password to your config. This will be the hash you generated above. Here are two examples:


rootpw --iscrypted $1$jp8guCvs$T8IiVIAlBUzxvvz8DaEcq.
rootpw --iscrypted $1$TLD/3yRf$ubHkGvhcinLD6zXbCnrLY1

IPTables

Remove any iptables firewall rules, save, and restart iptables.


iptables -F
service iptables save
service iptables restart

SELinux

Edit the SELinux config:


vi /etc/selinux/config

Disable it:


SELINUX=disabled

Reboot:


shutdown -r now

OR …. you might want to play around with SELinux settings:


getsebool -a | grep httpd_disable
setsebool -P httpd_disable_trans=1
getsebool -a | grep httpd_disable

Make sure apache is running:


service httpd start
service httpd status

DHCP Server and PXE Setup

Install and fire up a DHCPD server:


yum install dhcp
chkconfig --level 3 dhcpd on
service dhcpd start

Edit your DHCPD config file like this. Note that we’ve defined a subnet and added a single host that will be booted off of the network. We’ve added it’s MAC address so that we will match the correct host. We specify a ‘filename’ parameter to tell it what file to look for when booting up. This is what the PXE boot file that the system will try to pull down from our TFTP server.


vi  /etc/dhcpd.conf

The file will look like this:


ignore unknown-clients;
authoritative;
ddns-updates off;
ddns-update-style interim;
ignore client-updates;


allow booting;
allow bootp;

subnet 10.0.0.0 netmask 255.0.0.0
{
    default-lease-time 600;
    max-lease-time 7200;
    option subnet-mask 255.0.0.0;
    option broadcast-address 10.255.255.255;
    option routers 10.0.0.1;
    option domain-name-servers 10.0.0.1, 10.0.0.2;
    option domain-name "test.lab";

    range 10.0.0.2 10.0.0.100;
}

host mongo1
{
    hardware ethernet 08:00:27:26:D2:E4;
    fixed-address 10.0.0.101;
    option host-name "mongo1.test.lab";
    next-server 10.0.0.1;
    filename "pxelinux.0";
}

TFTP Server and PXE Setup

Enable the TFTP XINETD configuration.


vi /etc/xinetd.d/tftp
    disable = no

OR do this instead of editing the file:


chkconfig tftp on

Make sure it is started up:


chkconfig xinetd on
/sbin/service xinetd start

Copy the PXE boot files into the /tftpboot directory:


cd /tftpboot  # could be /var/lib/tftpboot
cp /usr/lib/syslinux/pxelinux.0 .  
cp /usr/lib/syslinux/menu.c32 .    

Copy more:


# RHEL
mkdir rhel5
cp -r /mnt/RHEL5.2_x64_disk1/images/pxeboot/* rhel5

# CentOS
mkdir -p centos/i386 centos/x86_64
CENTOS=/var/www/html/centos/6/os
cp $CENTOS/i386/images/pxeboot/* centos/i386
cp $CENTOS/x86_64/images/pxeboot/* centos/x86_64

Create a pexlinux.cfg dir and edit the default file:


mkdir pxelinux.cfg
vi pxelinux.cfg/default

The default file should look something like this. Notice that we are telling it where to find the kickstart config file (ks.cfg). This is what I used for RHEL.


DEFAULT menu.c32
PROMPT 0
TIMEOUT 300
ONTIMEOUT localdisk
MENU TITLE PXE Network Boot

LABEL localdisk
    MENU LABEL ^Local Hard Drive
    MENU DEFAULT
    LOCALBOOT 0


LABEL install_64bit
    MENU LABEL ^my build 1
    KERNEL rhel5/vmlinuz
    APPEND ks=http://10.0.0.1/ks.cfg initrd=rhel5/initrd.img ramdisk_size=100000

This is what I used for CentOS, it is almost the same thing:


DEFAULT menu.c32
PROMPT 0
TIMEOUT 300
ONTIMEOUT localdisk
MENU TITLE PXE Network Boot

LABEL localdisk
    MENU LABEL ^Local Hard Drive
    MENU DEFAULT
    LOCALBOOT 0


LABEL install_64bit
    MENU LABEL ^CentOS 6.0 (64-bit) Install
    KERNEL centos/x86_64/vmlinuz
    APPEND ks=http://NETINSTALL-HOST/ks/b64.ks initrd=centos/x86_64/initrd.img ramdisk_size=100000

Kickstart Configuration File ( ks.cfg )

Edit the ks.cfg file:


vi /var/www/html/ks.cfg

It will look something like this:


install
lang en_US.UTF-8
keyboard us
key --skip
text
skipx

url --url http://10.0.0.1/pub
#network --device eth0 --hostname KS-Client --bootproto=static --ip=192.168.0.151 --netmask=255.255.255.0
## also used on reconnecting to network for stage2
network --device eth0 --hostname KS-Client --bootproto=static --ip=10.0.0.101 --netmask=255.0.0.0
rootpw --iscrypted $1$TLD/3yRf$ubHkGvhcinLD6zXbCnrLY1
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --permissive
timezone --utc America/New_York

clearpart --all --drives=sda --initlabel
bootloader --location=mbr --driveorder=sda
part /boot --fstype ext3 --size=100
part swap --size=2000
part / --fstype ext3 --size=5000 --grow

%packages
@ Core
@ Base
openssh-clients
openssh-server


%post

wget http://10.0.0.1/pub/custom/python-simplejson-2.0.9-8.el5.x86_64.rpm
rpm -i python-simplejson-2.0.9-8.el5.x86_64.rpm

sed -i 's/10.0.0.101/192.168.0.101/' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/255.0.0.0/255.255.255.0/' /etc/sysconfig/network-scripts/ifcfg-eth0

Multiple Kickstart Configs

To setup multiple configurations and multiple hosts start by creating a new PXE Linux config for each host. It should be named based on the MAC address of the host.


cd /tftpboot/pxelinux.cfg
cp default 01-08-00-27-26-D2-E4
cp default 01-08-00-27-32-5B-63
cp default 01-08-00-27-58-A1-F2
cp default 01-08-00-27-A2-68-96

Edit each file to point to a different kickstart config file. This way you can create a unique configuration for each host.


sed -i 's/ks.cfg/ks_101.cfg/' 08-00-27-26-D2-E4
sed -i 's/ks.cfg/ks_102.cfg/' 08-00-27-32-5B-63
sed -i 's/ks.cfg/ks_103.cfg/' 08-00-27-58-A1-F2
sed -i 's/ks.cfg/ks_104.cfg/' 08-00-27-A2-68-96

Fix the names because PXE boot uses lower case. We initally create them with upper case because we just copy and paste them from console output or something similar.


for i in $( ls ); do mv $i `echo $i | tr [:upper:] [:lower:]`; done   ##

Edit the actual IPs for each host within it’s respective kickstart config file.


cp ks.cfg ks_101.cfg && sed -i 's/101/101/' ks_101.cfg
cp ks.cfg ks_102.cfg && sed -i 's/101/102/' ks_102.cfg
cp ks.cfg ks_103.cfg && sed -i 's/101/103/' ks_103.cfg
cp ks.cfg ks_104.cfg && sed -i 's/101/104/' ks_104.cfg

Remember to add new host entries in your DHCP configuraiton and restart dhcpd.


vi /etc/dhcpd.conf
service dhcpd restart

References