PXE Network Installation using Kickstart method


In my previous post, i have explained how to configure the network boot installation using ftp daemon. So after ftp starts, user have to manually install the linux according to their setup.

Here we are going to see to automatic installation of linux machine. ie., No need of manuall steps

Please make sure the following services are correctly configured and running.

1. DHCP
2. PXE
3. FTP

Step 1: Kickstart Configuration

[root@server.local ~]# mkdir /data/pxe
[root@server.local ~]# cp anaconda-ks.cfg /data/pxe
[root@server.local ~]# vi /data/pxe/anaconda-ks.cfg

install
ftp --server 192.168.1.5 --dir /var/ftp/redhat/5/i386/
lang en_US.UTF-8
keyboard us-acentos
xconfig --startxonboot
rootpw --iscrypted $13d35490GqgJeixe32VWXX
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc America/Los_Angeles
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=2048
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=5120

%packages
@admin-tools
@base
@core
@dialup
@editors
@gnome-desktop
@graphical-internet
@graphics
@java
@legacy-software-support
@office
@printing
@sound-and-video
@text-internet
@base-x
kexec-tools
iscsi-initiator-utils
keyutils
trousers
fipscheck
device-mapper-multipath
sgpio
emacs
bind
bind-chroot
bind-devel
caching-nameserver
compat-libstdc++-33
compat-glibc
gdb
ltrace
ntp
OpenIPMI-tools
screen
sendmail-cf
strace
sysstat
-bluez-utils

%post
/usr/bin/yum -y update >> /root/pxe_install.log 2>&1
/sbin/chkconfig ntpd on
/sbin/chkconfig named on

Step 2: NFS Server

[root@server.local ~]# vi /etc/exports

Add the below line

/data 192.168.1.0/24(ro,no_root_squash)

[root@server.local ~]# /etc/init.d/nfs restart

Step 3: Bootloader configuration

[root@server.local ~]# vi /tftpboot/pxelinux.cfg/default

Add the below lines in EOF

LABEL Redhat Enterprise Linux 5
KERNEL images/redhat/5/i386/vmlinuz
APPEND vga=normal initrd=images/redhat/5/i386/initrd.img network ks=nfs:192.168.1.5:/data/pxe/anaconda-ks.cfg

Step 4: Start or restart the necessary daemons

[root@server.local ~]# service vsftpd restart
[root@server.local ~]# service xinetd restart
[root@server.local ~]# service nfs restart
[root@server.local ~]# service dhcpd restart

Make the daemons start at boot level

[root@server.local ~]# chkconfig vsftpd --level 35 on
[root@server.local ~]# chkconfig xinetd --level 35 on
[root@server.local ~]# chkconfig nfs --level 35 on
[root@server.local ~]# chkconfig dhcpd --level 35 on

How To Setup CentOS PXE Linux Installation Server


In this post, we are going to see how to install and configure a server installation with several distribution Centos/Fedora/Redhat/Oracle Linux through the network as a base system using CentOS Server with DHCP,vsftp,TFTP,Xinet services.

The term PXE refers to the preboot execution environment (Preboot eXecution Environment).

The feature of this PXE is used to boot and install the operating system on computers via a network, so no need of manual installations.

DHCP/PXE Server:

server.local, IP address: 192.168.1.5

Step 1: Install and configure DHCP

[root@server.local ~]# yum install dhcp
[root@server.local ~]# vi /etc/dhcp/dhcpd.conf

ddns-update-style interim;
not authoritative;
option domain-name "example.com";
option domain-name-servers 192.168.1.100, 192.168.1.200;
option subnet-mask 255.255.255.0;
subnet 192.168.1.0 netmask 255.255.255.0
{
authoritative;
range 192.168.1.10 192.168.1.254;;
allow unknown-clients;
allow booting;
allow bootp;
next-server 192.168.1.5;
filename "pxelinux.0";
}

Step 2: Install and configure VSFTP& TFTP

[root@server.local ~]# yum install vsftp
[root@server.local ~]# yum install tftp-server
[root@server.local ~]# vi /etc/xinetd.d/tftp

Change the disable variable to “no”

disable=no

Create the essential directories

[root@server.local ~]# mkdir /tftpboot/
[root@server.local ~]# mkdir /tftpboot/images
[root@server.local ~]# mkdir /tftpboot/pxelinux.cfg
[root@server.local ~]# chmod -R 777 /tftpboot/

Copy pxelinux.0 & menu.c32 files to /tftpboot directory

[root@server.local ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
[root@server.local ~]# cp /usr/lib/syslinux/menu.c32 /tftpboot/

Create the PXE menu config file

[root@server.local ~]# vi /tftpboot/pxelinux.cfg/default

DEFAULT menu.c32
PROMPT 0
TIMEOUT 600
MENU TITLE Network Installation

Step 3: Copy linux distribution source to /tftpboot directory

[root@server.local ~]# mkdir /mnt/cdrom
[root@server.local ~]# mount /dev/sr0 /mnt/cdrom

CentOS 6

[root@server.local ~]# mkdir /tftpboot/images/centos/6/x86_64/
[root@server.local ~]# mkdir /var/ftp/centos/6/x86_64/
[root@server.local ~]# cp -R /mnt/cdrom/* /var/ftp/centos/6/x86_64/
[root@server.local ~]# cp /var/ftp/centos/6/x86_64/images/pxeboot/vmlinuz /tftpboot/images/centos/6/x86_64/
[root@server.local ~]# cp /var/ftp/centos/6/x86_64/images/pxeboot/initrd.img /tftpboot/images/centos/6/x86_64/

Add Centos entry on PXE menu:

[root@server.local ~]# vi /tftpboot/pxelinux.cfg/default

Add the below lines in EOF

LABEL Centos 6 (x86_64)
KERNEL images/centos/6/x86_64/vmlinuz
APPEND vga=normal initrd=images/centos/6/x86_64/initrd.img ramdisk_size=32768
METHOD=ftp://192.168.1.5/centos/6/x86_64/

Redhat 5

[root@server.local ~]# mkdir /tftpboot/images/redhat/5/i386
[root@server.local ~]# mkdir /var/ftp/redhat/5/i386
[root@server.local ~]# cp -R /mnt/* /var/ftp/redhat/5/i386/
[root@server.local ~]# cp /var/ftp/redhat/5/i386/vmlinuz /tftpboot/images/redhat/5/i386/
[root@server.local ~]# cp /var/ftp/redhat/5/i386/initrd.img /tftpboot/images/redhat/5/i386/

Add Redhat entry on PXE menu:

[root@server.local ~]# vi /tftpboot/pxelinux.cfg/default

Add the below lines in EOF

LABEL Redhat Enterprise Linux 5
KERNEL images/redhat/5/i386/vmlinuz
APPEND vga=normal initrd=images/redhat/5/i386/initrd.img ramdisk_size=32768
METHOD=ftp://192.168.1.5/redhat/5/i386/

Step 4: Start or restart the necessary daemons

[root@server.local ~]# service vsftpd restart
[root@server.local ~]# service xinetd restart
[root@server.local ~]# service nfs restart
[root@server.local ~]# service dhcpd restart

Make the daemons start at boot level

[root@server.local ~]# chkconfig vsftpd --level 35 on
[root@server.local ~]# chkconfig xinetd --level 35 on
[root@server.local ~]# chkconfig nfs --level 35 on
[root@server.local ~]# chkconfig dhcpd --level 35 on

Now your PXE server is ready. Change your desktop boot level to network, after save and exit machine will boot from dhcp and PXE menu will appear to select the OS to be install on the desktop.