Use Kickstart to automate a Red Hat Enterprise Linux OS installation

After a Red Hat Enterprise Linux OS installation, a file named anaconda-ks.cfg is created in the home directory of the root user. This file contains all settings used while installing this server. In this article, you'll learn how to modify the anaconda-ks.cfg file manually and use it to

    Requires Free Membership to View

install RHEL on other servers.

Before using any anaconda-ks.cfg file to install your next server, you need to modify it, even if you want to use the same settings. This is because all disk operations have been commented out to prevent you from wiping the contents of a disk. In Listing 1, you can see what an anaconda-ks.cfg file can hold:

Example contents of the anaconda-ks.cfg file

[root@hnl ~]# cat anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.

lang en_US.UTF-8
keyboard us-acentos
network --onboot no --device p6p1 --bootproto static --ip --netmask --noipv6 --hostname hnl.example.com
network --onboot no --device wlan0 --noipv4 --noipv6
rootpw  --iscrypted $6$tvvRd3Vd2ZBQ26yi$TdQs4ndaKXny0CkvtmENBeFkCs2eRnhzeobyGR50BEN02OdKCmr.x0yAkY9nhk.0fuMWB7ysPTqjXzEOzv6ax1
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Europe/Amsterdam
bootloader --location=mbr --driveorder=sda --append=" rhgb crashkernel=auto 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 --none

#part /boot --fstype=ext4 --onpart=sda1 --noformat
#part pv.008002 --onpart=sda2 --noformat

#volgroup vg_hnl --pesize=4096 --useexisting --noformat pv.008002
#logvol /home --fstype=ext4 --name=lv_home --vgname=vg_hnl --useexisting
#logvol / --fstype=ext4 --name=lv_root --vgname=vg_hnl --useexisting
#logvol swap --name=lv_swap --vgname=vg_hnl --useexisting --noformat
#logvol  --name=target --vgname=vg_hnl --useexisting --noformat

repo --name="Red Hat Enterprise Linux"  --baseurl=cdrom:sr0 --cost=100


The anaconda-ks.cfg file starts with some generic settings. The first line that needs attention is the network line. It contains the device name --device p6p1. This device name is related to the specific hardware configuration of the server the file was created on -- it might not work on other servers -- so replace it with --device eth0. Also, it is not a good idea to leave a fixed IP address in the configuration file, so replace --bootproto static --ip --netmask with --bootproto dhcp.

Another parameter that requires attention is the line with the encrypted root password that was used while installing the server. If you want the installation process to prompt for a root password, you can just remove this line completely.

A bit farther in the example file are details regarding where partitions and logical volumes were created. In the example, no sizes are specified. If you want to specify partition sizes, add the --size option to each line where a partition or a logical volume is created. Also, consider the syntax used to create the LVM environment, as this cannot be done from the graphical interface system-config-kickstart.

More Red Hat Enterprise Linux tips

Linux performance optimization

DNS server setup for RHEL

Overview of RHEV and RHEL

After the definition of partitions and logical volumes, specify the repository to be used. This parameter likely needs to be changed. The --baseurl parameter contains a URL that refers to the installation URL that you want to use. For instance, it can read --baseurl=http://server1.example.com/install to refer to an http installation server.

In the last important section, we specify the packages to be installed. Everything that starts with an @ -- like @base -- refers to an RPM package group. At the bottom of the list, individual packages are added by mentioning the name of the packages.

After making all required modifications to your Kickstart file, you should save it to a location where it can be accessed when installing your next server. For easy access, it is a good idea to put it on a Web server. Once it is copied to the Web server, you can access it from the boot prompt of the system that you want to install. When the installation program loads, press Tab and enter the URL to be used for the installation, like http://yourwebserver/anaconda-ks.cfg. If the file can be accessed from that location, the installation will start smoothly, and it will only stop for those parts of the configuration that have not been specified.

ABOUT THE AUTHOR: Sander van Vugt is an independent trainer and consultant based in the Netherlands. He is an expert in Linux high availability, virtualization and performance, and has completed several projects that implement all three. He is also the writer of various Linux-related books, such as Beginning the Linux Command Line, Beginning Ubuntu Server Administration and Pro Ubuntu Server Administration.

This was first published in January 2013

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.