CentOS Kickstart

Introduction

This guide is very similar in style to the Ubuntu autoinstall guide, in the sense that it makes a file to pre-define certain things. It is not as extensive as the other one, though, in modifying the ISOLINUX config files and so on.

When creating a Kickstart file, here are some simple things to know.

When the OS boots with the kickstarter, the install will fail on any mis-configured or unknown options. That makes testing a bit of a pain if you're creating one from scratch. It's not impossible to do that, but if you want to, you can create one more easily using the kickstarter GUI application that ships with CentOS. You'd have to install it first before using it:

yum install system-config-kickstart
system-config-kickstart

Download ISO

The first thing to do is download the CentOS ISO you'd like to install. In this example, I'm using CentOS 6.6 (which is rather old). The kickstart file should work with newer installs as well.

wget http://archive.kernel.org/centos-vault/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso

Sample Kicsktarter File

Here's a file I make to go through a quick text install. When finished, the file is saved as ks.cfg and needs to go into the ISOLINUX directory on the ISO.

Do a text installation, and use the contents from the ISO:

install
cdrom
text
skipx

Use locale settings:

keyboard us
lang en_US

As well as timezone:

timezone --isUtc America/Denver

I prefer to disable the firewall:

firewall --disabled

As well as SELinux:

selinux --disabled

Use shadow authentication for the passwords (which is the default on a system anyway):

auth --useshadow

Create a generic user with password insecure:

user --name=centos --groups=wheel --password=insecure --shell=/bin/bash

Set the root password to insecure as well:

rootpw insecure

Shut down the system when all is finished:

poweroff

Partitioning

Setting up the partitions is a tricky step, so refer to the documentation (or even better, the GUI) to set exactly what you want.

In this configuration, here's step by step what is happening.

The original bootloader is eradicated:

zerombr

The new bootloader is installed in the MBR:

bootloader --location=mbr

All existing partitions are removed:

clearpart --all --initlabel

Create a /boot partition, ext2 filesytem, 256 MB:

part /boot --fstype=ext3 --size=256

Create a swap partition, letting CentOS set the size:

part swap --fstype=swap --recommended

Create an ext4 filesystem for /, using the remaining space on the partition:

part / --fstype=ext4 --grow --size=1

Packages

At the end of the kickstarter file, you can add some specific packages you'd like installed along with the base system. By default there's quite a lot, but you may want to add more, based on the ISO you're using to install it.

You can display the packages that are available by mounting the ISO and looking int the Packages directory.

Add the list to the kickstarter file. Ignore missing ones just in case, so the install will continue if there's not one installing. This is just using dhclient as an example.

%packages --ignoremissing
dhclient

Some additional packages:

@ base
@ core
coreutils
yum
rpm
e2fsprogs
openssh-server
openssh-clients
dhclient

Creating the ISO

Mount the original ISO, and copy its contents somewhere else:

mkdir /tmp/source-iso
mkdir /tmp/target-iso
mount -o loop,ro centos.iso /tmp/source-iso
cp -r /tmp/source-iso/* /tmp/target-iso/

The original ISO won't be needed any more, so it can be unmounted if you feel like it:

umount /tmp/source-iso

Once you've created the kickstarter config file, save it asks.cfg and copy it into the ISOLINUX directory:

cp ks.cfg /tmp/source-iso/isolinux

Update the ISOLINUX config file to tell it where the kickstarter config file is. Edit the file /tmp/source-iso/isolinux/isolinx.cfg

Update the first append initrd entry to point to the ks.cfg file:

append initrd=initrd.img ks=cdrom:/ks.cfg

Finally, build the new bootable ISO with the config file:

cd /tmp/target-iso
mkisofs -o /tmp/centos-kickstart.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/. .

And boot the ISO as normal. You've got an automated install!