In this article I will share separate sections of a kickstart file which can be used based on your requirement.
A sample kickstart configuration file can be collected from here
If you are starting with scratch to create a custom kickstart file it is always a good idea to use anaconda-ks.cfg which is available in the home folder of the 'root' user which can give you the different sections which are needed to do a scratch installation.
I will try to explain the various options which can be selected for different section in the kickstart.
Below is the link from Red Hat which has an overview of all the supported parameters in kickstart file for RHEL 7 / CentOS 7.
Kickstart Syntax for Red Hat Enterprise Linux 7
I will not be able to explain every parameter, but will try to explain the ones which are mostly used, if you want any additional help feel free to post the same in your comments and I can add those as well.
Create custom repository
Ideally the default directory in the Red Hat which contains all the list of rpms is "Packages" but assuming you would like to involve an additional repo to your list with some additional rpms.
For eg on my TFTP server using which I will initiate a PXE installation using these kickstart files, I have repository as below path
# cd /root/repo/rhel7_64
Here I will create an additional directory which will contain all the additional rpms which I want to include in my repository
# mkdir ExtraPackages
Once all rpms are copied here, I have to execute
# createrepo /root/repo/rhel7_64/ExtraPackages/
This will configure it as a repo by creating needed xml files and repodata.
Next add this line in the kickstart file
## Additional repository
repo --name="ExtraPackages" --baseurl=file:///run/install/repo/ExtraPackages
Mode of Installation
Based on your requirement select the option
# For text based installation
# For graphical based installation
Keyboard Layout and System Language
Most of us normally use the standard "us" and "US-English" but there are many more options which can be used based on your region.
To get the list of supported keyboard layout
# localectl list-keymaps
To get the list of supported system language
# localectl list-locales
To check the currently set values
System Locale: LANG=en_US.utf8
VC Keymap: us
X11 Layout: us
Based on your requirement fill the value in the kickstart file
# System keyboard
# System language
Installation media details
You have to provide the details of the server/location from which the installation of RHEL will be initiated.
For eg: if a DVD is used for installation then use
# Installation Media
For NFS server
# Installation Media
nfs --server=10.43.138.1 --dir=/root/repo/rhel7_64
For HTTP, HTTPS, FTP server
url --url http://server/path
url --url ftp://username:password@server/path
Here you can define the network configuration of the target node based on your requirement.
If you have a DHCP server which will give the details of the network then
To assign static IP details below are some sample configuration
For multiple interfaces with bond configuration using MII bonding and IPv6 disabled
For multiple interfaces with bond configuration using ARP bonding and IPv6 disabled
For individual interfaces (without bond)
Configure Disk Partitioning
This is one of the other important part of kickstart configuration wherein you have to give the complete layout of your partitioning scheme
The first part of this is always to clear the existing partition table unless you want to retain some disk.
For my case I want to completely scratch install my system
# Clear existing data
clearpart --all --initlabel
The zerombr command initialises unused partition tables.
NOTE: For the sake of this article I will use "clearpart --all" as I have to wipe out complete disk drives
For setting an ext4 partition with a simple layout
# Disk Partitioning
autopart --type=plain --fstype=ext4
For setting an ext4 partition with a software RAID 1 + LVM.
Here my setup is having two disk (each with 838GB space) hence I am create Physical Volume accordingly, you can modify the value based on your disk size. You can also use "--size 1 --grow" if you do not wish to restrictively define a size for your physical volume and this will take the maximum available space in your disks.
# -- raid part for boot --
part raid.sda0 --size 512 --asprimary --ondrive=sda
part raid.sdb0 --size 512 --asprimary --ondrive=sdb
# -- raid part for pv.1 --
part raid.sda2 --size 821616 --ondrive=sda
part raid.sdb2 --size 821616 --ondrive=sdb
# -- raid part for root --
part raid.sda1 --size 12288 --ondrive=sda
part raid.sdb1 --size 12288 --ondrive=sdb
# -- raid part for swap --
part raid.sda3 --size 12288 --ondrive=sda
part raid.sdb3 --size 12288 --ondrive=sdb
# Raid device creation
raid /boot --fstype ext4 --device md0 --level=RAID1 raid.sda0 raid.sdb0
raid pv.1 --device md2 --level=RAID1 raid.sda2 raid.sdb2
raid / --fstype ext4 --device md1 --level=RAID1 raid.sda1 raid.sdb1
raid swap --fstype swap --device md3 --level=RAID1 raid.sda3 raid.sdb3
# Volume group and logical volume creation
volgroup vg00 --pesize=65536 pv.1
logvol /var --fstype ext4 --vgname vg00 --size=16384 --name=var
logvol /tmp --fstype ext4 --vgname vg00 --size=24576 --name=tmp
logvol /home --fstype ext4 --vgname vg00 --size=8192 --name=home
logvol /opt --fstype ext4 --vgname vg00 --size=16384 --name=opt
logvol /usr --fstype ext4 --vgname vg00 --size=32768 --name=usr
logvol /var/log --fstype ext4 --vgname vg00 --size=1 --grow --name=log
For setting an ext4 partition with only LVM.
Here my setup has a single disk (sda) and my physical volume is configured to use all the available space on the disk to create and configure the partition layout
part /boot --size 512 --asprimary --fstype=ext4 --ondrive=sda
part pv.1 --size 1 --grow --fstype=ext4 --ondrive=sda
volgroup system --pesize=32768 pv.1
logvol / --fstype ext4 --vgname system --size=8192 --name=root
logvol /var --fstype ext4 --vgname system --size=16384 --name=var
logvol /tmp --fstype ext4 --vgname system --size=40960 --name=tmp
logvol swap --vgname system --size=4096 --name=swap
logvol /opt --fstype ext4 --vgname system --size=8192 --name=opt
logvol /opt/deep --fstype ext4 --vgname system --size=6144 --name=deep
logvol /opt/deep/log --fstype ext4 --vgname system --size=20480 --name=deeplog
logvol /var/opt/data--fstype ext4 --vgname system --size=1 --grow --name=mybackup
To get the list of supported timezone variables in the kickstart on a RHEL 7 node execute below command
# timedatectl list-timezones
This will give a long list of available timezones which can be used here, for me
# System timezone
timezone --utc Asia/Kolkata
Here you have to give a password of the 'root' user which can be in below formats
You can create an encrypted password with sha512 crypt-compatible hash using below command
# python -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())'
Once you have the encrypted password
rootpw --iscrypted $1$oVhMpzps$6FeGBc1uF2JmG2xTeSWML0
You can also lock the 'root' user from logging in via console using "--lock". This option will also disable the Root Passwordscreens in both the graphical and text-based manual installation.
List of Packages to be installed
Here you can give a list of groups or individual rpms which you would like to be installed on your node, additionally you can also give a list of rpms which you want to be removed from your node. This is useful wherein you have selected a "Group" for package installation but still some of the rpms from this group is not needed hence the same can be removed during installation
To get the details of the available group in a RHEL 7 DVD
# yum group list ids
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Available Environment Groups:
Minimal Install (minimal)
Infrastructure Server (infrastructure-server-environment)
File and Print Server (file-print-server-environment)
Basic Web Server (web-server-environment)
Virtualization Host (virtualization-host-environment)
Server with GUI (graphical-server-environment)
Compatibility Libraries (compat-libraries)
Console Internet Tools (console-internet)
Development Tools (development)
Graphical Administration Tools (graphical-admin-tools)
Legacy UNIX Compatibility (legacy-unix)
Scientific Support (scientific)
Security Tools (security-tools)
Smart Card Support (smart-card)
System Administration Tools (system-admin-tools)
System Management (system-management)
So here the id mentioned within ( ) can be used in the below section, By default we use @Core and @Base for minimal installation
# list of packages to be installed
# Groups to be installed
@ Base --nodefaults
# Additional rpms to be installed
# rpms to be removed
NOTE: The rpms to be removed must be started with a minus sign (-) but a (+) is not needed for any rpms you want to be installed additionally
This section is one of the most useful feature as here you can do the real magic of customisation based on your organisation requirement.
For eg once the installation is complete there are some custom scripts which are available on the node which I want to execute and save the date and time when the installation completed.
%post --interpreter=shell --log=/var/log/kickstart_post.log
echo "Executing post installation scripts"
echo "Installation Completed"
Similarly %pre section can be used to perform some activity before starting the installation based on the requirement.
There are many more sections in a kickstart file which goes out of scope for this article, but if you feel you need any additional information on any of the parameter and assuming I have information on the same please let me know in the comment section and I will try to help you out.
I hope this article was helpful.