Setting up Kickstart server in centos 6.3, by Joe Moore at databasejoe.com

Print Friendly, PDF & Email

Here's some more possible help with PXE topics from Joe Moore at https://databasejoe.com/

I can't vouch for it's accuracy myself of course, as I don't use Centos.

———————————————————–

Setting up Kickstart server in centos 6.3

Setup TFTP Server;

Yum install tftp-server
Open "vi /etc/xinetd.d/tftp" to change disable to "no"
Service xinetd start
Chkconfig xinetd on
Yum install syslinux
Copy following files
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/memdisk /var/lib/tftpboot/
cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot/

Mkdir /var/lib/tftpboot/pxelinux.cfg
Create directory for each pxe boot image

mkdir –p /var/lib/tftpboot/images/centos/x86_64/6.3
mkdir –p /var/lib/tftpboot/images/centos/i386/6.3

Download centos DVD or minimal cd
Mount the iso dvd
Copy vmlinux and initrd.img from /images/pxeboot on dvd or download these files from centos mirror for the minimal cd

cp /media/CentOS_6.3_Final/images/pxeboot/initrd.img /var/lib/tftpboot/images/centos/x86_64/6.3
cp /media/CentOS_6.3_Final/images/pxeboot/vmlinuz /var/lib/tftpboot/images/centos/x86_64/6.3

Install dhcp server : yum install dhcp
Configure dhcp server: vi /etc/dhcp/dhcpd.conf
Add the following

[root@kickstart pub]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
option domain-name "packet3.co.uk";
option domain-name-servers ns1.packet3.local;
default-lease-time 600;
max-lease-time 7200;
authoritative;

allow booting;
allow bootp;
next-server 192.168.3.5;
filename "pxelinux.0";

subnet 192.168.3.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.3.100 192.168.3.254;
option broadcast-address 192.168.3.255;
option routers 192.168.3.1;
option domain-name-servers 192.168.1.1, 192.168.3.1;
}

[root@kickstart pub]#

Restart dhcpd server: service dhcp restart
Chkconfig dhcpd on
Adjust firewall settings if needed
iptables -A INPUT –p udp –dport 67 -j ACCEPT
iptables -A INPUT –p udp –dport 68 -j ACCEPT

Create a basic menu to select OS: vim /var/lib/tftpboot/pxelinux.cfg/default
Now add the following lines to that file:
[root@kickstart pub]# cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 30

menu title Packet3 Kickstart Menu
LABEL wds
MENU LABEL wds
APPEND 192.168.2.1::pxeboot.0
LABEL Centos 6.3 i386 Minimal
MENU LABEL Centos 6.3 i386
KERNEL images/centos/i386/6.3-min/pxeboot/vmlinuz
APPEND initrd=images/centos/i386/6.3-min/pxeboot/initrd.img ks=ftp://192.168.3.5/pub/ks.cfg
ramdisk_size=100000
LABEL Ubuntu Server Install 12.04
MENU LABEL Ubuntu server 12.04
KERNEL images/ubuntu/install/netboot/ubuntu-installer/i386/linux
APPEND debian-installer/locale=en_GB console-setup/layoutcode=uk ks=ftp://192.168.3.5/pub/Ubuntu/preseed/ks.cfg preseed/url=ftp://192.168.3.5/pub/Ubuntu/preseed/preseed.cfg initrd=images/ubuntu/install/netboot/ubuntu-installer/i386/initrd.gz
[root@kickstart pub]#

Setup FTP server

Yum install vsftpd
Insert dvd of centos 6.3 and mount it
Copy the installation files:
cp -ar /media/CentOS_6.3_Final/. /var/ftp/pub/
don't forget dot ".", it will copy hidden files as well

Create empty kickstart file: touch /var/ftp/pub/ks.cfg
Set selinux permissions
chcon -R -t public_content_t /var/ftp/

Setup firewall if needed
iptables -A INPUT -p tcp -m state –state NEW –dport 21 -j ACCEPT

Seave firewall: service iptables save
Start ftp service: service vsftpd restart
Chkconfig vsftpd on

Setup Kickstart File

Add the following to the kickstart file

[root@kickstart pub]# cat /var/ftp/pub/ks.cfg

text
install
url –url ftp://192.168.3.5/pub
lang en_US.UTF-8
keyboard uk
#network –device eth0 bootproto dhcp
%include /tmp/test.ks
rootpw –iscrypted $6$T30a5xlxof0MeHd2$KG8ADYyNWcxOMxgnFQl93hhsYuavy/dlbFcb4vg6iIwdZyIYTb361VIHEuIPLUfFPy5w7s9pTAeaxeLnzCzli1
firewall –service=ssh
authconfig –enableshadow –passalgo=sha512 –enablefingerprint
selinux –disabled
timezone Etc/GMT
bootloader –location=mbr –driveorder=sda –append="crashkernel=auto rhgb quiet"
zerombr yes
clearpart –all –drives=sda –initlabel
autopart
reboot
firstboot –disable
%pre
#!/bin/bash
exec < /dev/tty3 > /dev/tty3
chvt 3
LOGFILE=/tmp/ks-pre.log
echo
echo "##################################"
echo "# Running Pre Setup Configuration #"
echo "##################################"

#presetup script
CONFIRM=no
while [ "$CONFIRM" != "y" ]
do
echo -n "Hostname(or leave black for dhcp):"
read HOSTNAME
if [ "$HOSTNAME" == "" ]
then
HOSTLINE="network –device=eth0 –bootproto=dhcp"
echo -e -n "\e[00;31mConfigure OS to use DHCP?(y/n): \e[00m"
read CONFIRM
else
echo -n "IP Address: "
read IPADDRESS
echo -e -n "Hostname: \e[01;36m$HOSTNAME \e[00m"
echo -e -n "IP Address: \e[01;36m$IPADDRESS \e[00m"
HOSTLINE="network –device=eth0 –bootproto=static –ip=$IPADDRESS –netmask=255.255.255.0 –gateway=192.168.3.1 –nameserver=192.168.3.3 –hostname=$HOSTNAME"
echo -e -n "Is the above configuration correct?(y/n): "
read CONFIRM
fi
done
echo $HOSTLINE > /tmp/test.ks
hostname $HOSTNAME
2>&1 | /usr/bin/tee $LOGFILE
chvt 1
exec < /dev/tty1 > /dev/tty1
%post –nochroot –log=/root/my-post-log
echo "#############################"
echo "# RUNNING POST INSTALL CONF #"
echo "#############################"
#Prevent yum downloading and installing future kernels
echo "exclude=kernel*" >> /etc/yum.conf
#update the system
yum update -y
#yum groupinstall "base" -y
#yum groupinstall "Development Tools" -y
useradd -m joe
echo 80min700 | passwd –stdin joe
chvt 1
exec < /dev/tty1 > /dev/tty1
%end

[root@kickstart pub]#