Wednesday, November 16, 2011

step by step guide to Redhat KickStart Installation

step by step guide to Redhat KickStart Installation

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


The kickstart file has 4 sections: pre, configuration, packages and post.
The pre section is generally used to check for certain hardware types or configurations and act upon that data. The pre is not used in this scenario.
The configuration, sets up the network, video, hard disk, locale, etc.
The packages lists which packages to install or (with a ‘-‘) not install.
The post is how all the third party software is added, the system is customized, and environment is setup.
The post section executes immediately after loading the OS packages, but is finished before the OS reboots for the first time.  Because there are some things which do not load properly until the full OS is booted, a finishing script is placed on the system to run on first boot.  
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kick start is a hand free installation of Redhat server on multiple machine.

Plan:
- Any successfully installed redhat system creates /root/anaconda-ks.cfg file. Based on this file you can add or remove packages.
- Or use the command System-Config-Kickstart to create a new ks file based on your requirement.
- Define your OS location either using ftp, nfs, or http
- Start the kickstart installation.

================================================
detail to follow,
 ===============================================

Before setting up your kickstart environment, first you better set up yum repo so that you can install all required softwares.

A. a. To set up your yum, just create the following file with the info below.

# createrepo /opt/RHL6.1/Packages
[jay@sama ~]$ cat /etc/yum.repos.d/file.repo
[RHEL-Repository]
name=RHEL repository
baseurl=file:///opt/RHL6.1/Packages
enabled=1
gpgcheck=0

b. Set up nfs server.
[root@sama ~]# yum install nfs*
[jay@sama ~]$ cat /etc/exports
#/opt/RHL6.1/Packages   *(rw,sync)
/opt/RHL6.1     *(rw,sync)

[root@sama ~]# service nfs reload

c. set up web server.
[root@sama ~]# yum -y install httpd
[root@sama ~]# service httpd start

[root@sama html]# vi index.html
<html>
<title>This is a test page</title>
<body>
This is a test page
</body>
</html>

confirm that you can access your website,
type http://192.168.10.110/ on your browser and press enter, you should be able to see "This is a test page page".

B. Now, you can copy your OS DVD copy on your web server.

# mkdir /OS; mount -o loop OS_Image.iso /OS; cd /OS
# cp -a * /var/www/html/yum/

verify that you can access http://192.168.10.110/yum

make sure that you can access the site from other systems on the network. if it failed, disable firewall (iptables).
# /etc/init.d/iptables stop


C. Now, real fun begins, Create a kickstart file

a. you can use anaconda-ks.cfg file as a template that is created during the first time installation of the Linux OS. Modify the values based on your requirement or

the environment.

b. Create kickstart config file using the system-config-kickstart command utility and select different parameters based on your environment. Note: make sure to instal

kickstart config package to use this feature.

here is the sample file,

[root@sama html]# cat /var/www/html/ks.cfg
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
#cdrom
nfs --server=192.168.10.110 --dir=/opt/RHL6.1
lang en_US.UTF-8
keyboard us
#network --onboot no --device eth0 --noipv4 --noipv6
network --device eth0 --bootproto static --ip 192.168.10.150 --netmask 255.255.255.0 --gateway 192.168.10.110 --hostname kickRH6.1.local
rootpw  --iscrypted $6$dsXNrQw2LZLmKFLZ$55Pxwi.6bJhI3QCxembF5lRD9hrjd15b5wx3caJZVcxQC8yTEc0cz2GyVeR5s9Ao4ZxnDvFyDLWBVy9Oi2SGC0
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto 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 --linux --drives=sda

#part  --onpart=sda1 --format
part /boot --fstype=ext4 --size=500
part pv.008003 --grow --size=1

volgroup vg_kickRH6.1 --pesize=4096 pv.008003
logvol / --fstype=ext4 --name=lv_root --vgname=vg_kickRH6.1 --grow --size=1024 --maxsize=51200
logvol swap --name=lv_swap --vgname=vg_kickRH6.1 --grow --size=2032 --maxsize=4064
repo --name="Red Hat Enterprise Linux"  --baseurl=http://192.168.10.110/yum --cost=100

%packages
@base
@client-mgmt-tools
@console-internet
@core
@debugging
@basic-desktop
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@hardware-monitoring
@internet-browser
@java-platform
@kde-desktop
@large-systems
@mysql-client
@mysql
@nepali-support
@network-file-system-client
@performance
@perl-runtime
@postgresql-client
@postgresql
@remote-desktop-clients
@server-platform
@server-policy
@system-admin-tools
@web-server
@x11
mtools
pax
python-dmidecode
oddjob
sgpio
genisoimage
wodim
qt-mysql
certmonger
pam_krb5
krb5-workstation
perl-DBD-MySQL
perl-DBD-SQLite
rdesktop
crypto-utils
certmonger
perl-CGI
%end
%post
(
# Disable some services and create normal user with encripted password.
chkconfig --level 3 ip6tables off
useradd -p '$6$OY1GbBYr

$MJI1dgQK23CBRzNyAEWGupxMRd2Hhwovr0cID6CtSgX7TSnLpPTR0rYNJ.AgshZzyK6QhPSWQZ0ifP9ky8HFl.' jay
) 2>&1 | tee /root/post-install.log
echo "Installation completed !!"
echo "All unauthorized activities will be monitored">>/etc/issue
%end

D. validate the kickstart configuration file with ksvalidator command
# ksvalidator /var/www/html/ks.cfg
Note: If there is an mistake or typos, you will get an error.

E. Confirm the configuration file is available form the browser.
Either type the full path on the browser or use elinks to verify.
[root@sama html]# elinks 192.168.10.110/ks.cfg

*Make sure ks.cfg file has at least 644 permission.
Now you kickstart configuration is available for installer using the web.

Now, use your installer, if you are using redhat use boot.iso, centos-->> CentOS*netinstall.iso, sciencefic linux SL*boot.iso file to install. You can use any iso file

to install any OS type but make sure to use right 32 or 64 bit image.

F. When you boot the system using any boot image, at the grub menu list, press the tab and type the following values at the prompt

linux ks=http://192.168.10.110/ks.cfg

press enter and you are good to go. You should have system installed with a normal user which you can use to login.

boot options
linux ks=ftp://myserver.com/ks.conf
linux ks=http://domain.com/path/ks.conf

linux ks=nfs:servername:/path/ks.conf
 
================================
for the post installation entry
--------------------------------
%post --nochroot

###### NFS mounts ######

mkdir /mnt/sysimage/opt/users
mkdir /mnt/sysimage/home
echo "192.168.10.110 sama sama.expanor.local >>/mnt/sysimage/etc/hosts"
echo "sama:/home/users /opt/users nfs rw,bg,intr,soft 1 2" >> /mnt/sysimage/etc/fstab
##echo "d2:/vol/root/home /home nfs rw,bg,intr,soft 0 0" >> /mnt/sysimage/etc/fstab
 

No comments:

Post a Comment