Kickstart could help you to simplify Linux server installation.


Here, we would like to create a new CentOS 7.2 ISO image which encloses a modified installation process, such as : ntp and open-vm-tools. Kickstart is already installed on many Linux distributions like fedora, REHL, CentOS …

Kickstart configuration file

We shall start from the existing “anaconda-ks.cfg” installation file :

[root@ceph-admin ~]# cp -p anaconda-ks.cfg ks.cfg
[root@ceph-admin centos]# cat ks.cfg
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
# Use graphical install
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=ch-fr --xlayouts='ch (fr)'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=eno16777984 --onboot=off --ipv6=auto
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$NHMI3Ey2TD3dmOS8$O6U0.VdpJ/1FwceBWD4gunvZ.WRRbjbN0pOuqe/Vg49N4t1kZFtpnh/cjQFmQOZgDv/9Hzjr7BKgyQVWDJurq.
# System services
services --disabled="chronyd"
# System timezone
timezone Europe/Zurich --isUtc --nontp
user --name=wou --password=$6$uheKlDwTDAxF.2E2$LudKbvMIp0ZeuH03UrjiUK9DE2jfAZFMqJl5WtPTra3Ev4OZIQeRBIpi8Li7pnlwAZvo41DcBg1SzlKR3xoXT0 --iscrypted --gecos="wou"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

# we don't need SELinux for labs :
selinux --disabled

# we want to reboot after installation :


%addon com_redhat_kdump --enable --reserve-mb='auto'


# post installation
/usr/bin/systemctl disable NetworkManager
/usr/bin/systemctl disable firewalld
/usr/bin/systemctl enable ntpd
/usr/bin/yum update -y --skip-broken
exit 0

New ISO image construction

Create a temporary directory :

[root@ceph-admin ~]# mkdir -p /tmp/iso

And copy CentOS 7.2 ISO image to this directory :

[root@ceph-admin ~]# cd /tmp/iso
[root@ceph-admin iso]# ls

Mount the ISO image :

[root@ceph-admin iso]# mount -o loop CentOS-7-x86_64-DVD-1511.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only

Copy files from mounted ISO image :

[root@ceph-admin iso]# mkdir -p /tmp/centos
[root@ceph-admin iso]# cd /tmp/centos
[root@ceph-admin centos]# cp -r /mnt/. .

Edit isolinux.cfg to add a new menu :

[root@ceph-admin centos]# cat isolinux/isolinux.cfg
default vesamenu.c32
timeout 600

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title CentOS 7
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

# custom menu (Kickstart)
label kickstart
  menu label ^Install CentOS 7 (version Frederic Wou)
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ks.cfg

label linux
  menu label ^Install CentOS 7
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

label check
  menu label Test this ^media & install CentOS 7
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

menu separator # insert an empty line

# utilities submenu
menu begin ^Troubleshooting
  menu title Troubleshooting

label vesa
  menu indent count 5
  menu label Install CentOS 7 in ^basic graphics mode
  text help
        Try this option out if you're having trouble installing
        CentOS 7.
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet

label rescue
  menu indent count 5
  menu label ^Rescue a CentOS system
  text help
        If the system will not boot, this lets you access files
        and edit config files to try to get it booting again.
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet

label memtest
  menu label Run a ^memory test
  text help
        If your system is having issues, a problem with your
        system's memory may be the cause. Use this utility to
        see if the memory is working correctly.
  kernel memtest

menu separator # insert an empty line

label local
  menu label Boot from ^local drive
  localboot 0xffff

menu separator # insert an empty line
menu separator # insert an empty line

label returntomain
  menu label Return to ^main menu
  menu exit

menu end

Copy the Kickstart configuration file :

[root@ceph-admin centos]# cp ~/ks.cfg .

Additional RPMs

Create a new temporary directory :

[root@ceph-admin ~]# mkdir -p /tmp/download
[root@ceph-admin ~]# cd /tmp/download

Build the list of those additional RPMs :

[root@ceph-admin download]# rpm -qa | grep -iE "bind-utils|net-tools|ntp|tree|open-vm-tools" | tee rpm_list

Get dependencies :

[root@ceph-admin download]# (cat rpm_list | while read RPM ; do rpm -q --requires $RPM | cut -d"(" -f1 ; done) | sort -u > dependencies

Install “yum-utils” package :

[root@ceph-admin download]# yum -y install yum-utils.noarch

Retrieve URLs where you can download RPMs :

[root@ceph-admin download]# cat rpm_list dependencies | xargs yumdownloader --urls | egrep "^http" > rpm.wget

Install “wget” package” :

[root@ceph-admin download]# yum -y install wget

Download packages :

[root@ceph-admin download]# wget -nv -nc -i rpm.wget

Copy those RPMs to the “Package” directory :

[root@ceph-admin download]# cp -n *.rpm /tmp/centos/Packages/.

New ISO image

We don’t need the old ISO image mounted anymore :

[root@ceph-admin download]# umount /mnt

We don’t need the old ISO image itself anymore :

[root@ceph-admin download]# rm -rf /tmp/iso

Download “mkisofs (genisoimage)” package :

[root@ceph-admin download]# yum -y install genisoimage

It’s time to burn this image :

[root@ceph-admin download]# cd /tmp/centos
[root@ceph-admin centos]# mkisofs -o /tmp/frederic_wou.iso -b isolinux.bin -c -no-emul-boot -V 'CentOS 7.2 x86_64' -boot-load-size 4 -boot-info-table -R -J -v -T isolinux .

Install CentOS using this ISO image

We copy this image to our VMware ESXi server in order to create a new virtual machine, then we boot :












We saw this menu, “root” password and “wou” new account are automatically set :












After login, we are happy to discover that Kickstart did the job well :
















The update has been done as well :















PDF24    Send article as PDF   

7 thoughts on “Customize CentOS installations using Kickstart

  1. Hi,
    Thanks you for this great post !
    Everything works ! But I am unable to install RPM which are on my ISO!
    When I launch installer, i’ve got this :
    You have specified the package ” should be installed. This package does not exist. Would you like to ignore this package and continue with installation ?

    1. Hi,

      i need more details to help you. You need a WEB access to install RPMs using “yum”. But you already have some RPMS in your ISO image (don’t use minimal image !).

      1. you 2 solutions :
        1) You use “rpm -uvh /my_directory_where_my_RPMs_are my_rpm”.

        2) You copy your RPMs in any directory is. You have to use “createrepo” to create metadata, then define a new repository in /etc/yum.repos.d, then you can use “yum install” to install your RPMs.

        1. Thanks,
          But you are copying your RPM in a directory but you didn’t a ‘createrepo”
          So I dont understand how you custom ISO works…

  2. Hi,
    Thanks you wou,

    I am trying to do the same thing than you. I download the RPM, I copy them in the directory Packages and I add the entry in my ks file (tree, vim, open-vm-tools).

    There is something to do indicate where are the RPM ? comps.xml file ?


Leave a Reply

Your email address will not be published. Required fields are marked *