Kickstart Installation on RHEL/CentOS

Kickstart Installation

Hello readers, In this article I am going to walk you through kickstart installation, an automated installation method on RHEL based systems. I tested this on a CentOS 6.5 virtual machine. The process should be the same on other RHEL distro variations.

Kickstart

It is an automated way of installing the operating system. You set all the options in a config file which is then read by all the machine during installation. So you don’t have to manually answer all the questions that are generally asked during installation.
Here is a good explanation of kickstart from RedHat documentation.
Many system administrators would prefer to use an automated installation method to install Red Hat Enterprise Linux on their machines. To answer this need, Red Hat created the kickstart installation method. Using kickstart, a system administrator can create a single file containing the answers to all the questions that would normally be asked during a typical installation.
Kickstart files can be kept on a single server system and read by individual computers during the installation. This installation method can support the use of a single kickstart file to install Red Hat Enterprise Linux on multiple machines, making it ideal for network and system administrators.
Kickstart provides a way for users to automate a Red Hat Enterprise Linux installation.

Steps for kickstart installation

Here is a brief outline of the steps involved in automating installation using Kickstart
  • Create kickstart file that has all the installation options set
  • Create a boot disk with kickstart file
  • Or create a boot disk and have the kickstart file in the network
  • Make the OS installation tree available somewhere in the network (ftp, http, nfs)
  • Start the kickstart installation on new machines.

Kickstart configurator

Kickstart files are plain text files which can either be created by hand if you are an advanced user or using a GUI tool. I would reccommend going the GUI way if you are just starting. RedHat provides a kickstart configurator tool which can be installed as follows
# yum install system-config-kickstart
If you want to see how a kickstart file looks, take a look at anaconda-ks.cfg in /root directory of any RHEL/CentOS systems. This file gets generated and placed in /root directory on a newly installed machine.
Start the GUI tool using the system menu or from the terminal as follows
# system-config-kickstart
You will be welcomed with this screen
Kickstart Installation Scren 1
Most of the options are self-explanatory and fill in all the details as you would while installing the OS. You will also be able to select the packages that you want.
In the below installation option screen, select the one that suits your need. In this article I will show you how to do it via ftp and http.
Kickstart Installation Screen 2
When you select ftp or http method, the tool will ask you for ftp/http server url, password and path. Continue reading this article and you will find what to fill in this section. Once all the details are filled, save the file as ks.cfg or whatever you want it to be called, but remember it.

Creating bootdisk

You can either use your OS install disk or create a boot disk if you want by following the below process. You will be using this boot disk to boot the machine and then point it to the kickstart file later.
mkisofs is a tool provided by genisoimage package. Using this tool we can build iso files. Install it as follows.
# yum install genisoimage
Mount your RHEL/CentOS install DVD and copy isolinux directory
# mkdir /tmp/installdvd
# cp -R /path/to/mounted/dvd/isolinux /tmp/installdvd
# cd /tmp/installdvd
# chmod u+w isolinux/*
Create the iso image now
# cd /tmp/installdvd
# mkisofs -o file.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/
This will create an iso image named file.iso. Burn it to a dvd and now you have got a boot disk!

Kickstart via FTP

I am going to assume here that you have got a working ftp server (vsftpd) and anonymous access is allowed.

Copying install tree to ftp:

Now we are going to copy the install disk to our ftp root. Lets assume you have got an iso file of the CentOS install disk downloaded from the internet. Mount it and copy to ftp as follows.
# mkdir /mnt/centosdvd
# mount -o loop /path/to/centos-6.5-x86_64-dvd.iso /mnt/centosdvd
# mkdir /var/ftp/pub/centos65
# cp -aR /mnt/centosdvd/* /var/ftp/pub/centos65/

Copying kickstart file to ftp:

Copy the kickstart file that you created earlier using system-config-kickstart to the ftp root.
# cp /path/to/ks.cfg /var/ftp/pub/

Adjusting SELinux:

If you have SELinux enabled, you need to set proper context to the newly copied directories. We shall use semanage tool to make our changes persistent. If you haven’t already got policycoreutils-python package installed, install it now.
# yum install policycoreutils-python
# semanage fcontext -a -t public_content_t "/var/ftp/pub/centos65(/.*)?"
# restorecon -R /var/ftp/pub/centos65
That’ it. Lets assume our server’s ip address is 10.0.3.100. This is going to be our kickstart server serving ks.cfg and OS install files.
On your kickstart configurator tool, select ftp and enter ftp://10.0.3.100/pub/centos65 as the ftp url.

Kickstart via HTTP

I am going to assume here that you have a web server set up already.

Copying install tree to web server:

Lets copy the OS install disk to web root so that all new machines can download packages from this server. Assuming you still have the disk mounted from earlier tasks,
# mkdir /var/www/html/centos65
# cp -aR /mnt/centosdvd/* /var/www/html/centos65/

Copy kickstart file to web server:

# cp /path/to/ks.cfg /var/www/html/

Adjusting SELinux:

# semanage fcontext -a -t httpd_sys_content_t "/var/www/html/centos65(/.*)?"
# restorecon -R /var/www/html/centos65

Performing Kickstart installation

Alright, we have come to the final bit. Lets perform an automated installation on one of our new machine. Boot the machine with either the boot disk that you created earlier or using the OS install DVD. When you see the boot menu press TAB key to edit the boot option. Append the ks.cfg location as below,

For ftp setup

> vmlinuz initrd=initrd.img console=ttyS0 ks=ftp://10.0.3.100/pub/ks.cfg

For http setup

> vmlinuz initrd=initrd.img console=ttyS0 ks=http://10.0.3.100/ks.cfg
That’s it. Unattended kickstart installation will proceed. Enjoy a cup of coffee!
Hope you learnt something new today. Thanks for reading this article.

0 comments:

Post a Comment