Understanding the kickstart configuration file

The LiveCD creation process requires a kickstart configuration file. The format of this file is the same as the one used for automated installations. The kickstart file can include some basic system configuration items, the package manifest and a script to be run at the end of the build process.

A simple kickstart file

The following example is taken from the kickstart configuration file for the minimalistic LiveCD

Basic system configuration

Lines 1 to 6 are defining basic system configuration.

Line	 
1 	lang en_US.UTF-8
2 	keyboard us
3 	timezone US/Eastern
4 	auth --useshadow --enablemd5
5 	selinux --enforcing
6 	firewall --disabled

Yum repositories

Lines 8 to 11 are specifying the yum repositories used for the LiveCD creation. The LiveCD creation process involves the download of several RPM packages from the Internet. Therefore, your Internet connection speed will impact directly the length of the creation process. The kickstart configuration files we provide are using the official CentOS mirror (http://mirror.centos.org/centos/5/os/). We recommend you to use the closest CentOS mirror server from your location instead.

For example, if your closest mirror is http://mirror.stanford.edu/yum/pub/centos/, you will need to replace the 'http://mirror.centos.org/centos/' string with 'http://mirror.stanford.edu/yum/pub/centos/' in your kickstart configuration file. Some yum repositories are known to cause the livecd-creator script to abort. See the Troubleshooting section for more information.

Line 
8 	repo --name=a-base    --baseurl=http://mirror.centos.org/centos/5/os/$basearch
9 	repo --name=a-updates --baseurl=http://mirror.centos.org/centos/5/updates/$basearch
10 	#repo --name=a-extras  --baseurl=http://mirror.centos.org/centos/5/extras/$basearch
11 	repo --name=a-live    --baseurl=http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live

Package manifest

Lines 13 to 23 contain the package manifest. Individual packages may be installed by giving the name of their RPM (excluding the version and platform information).

Line 
13 	%packages
14 	bash
15 	kernel
16 	syslinux
17 	passwd
18 	policycoreutils
19 	chkconfig
20 	authconfig
21 	rootfiles
22 	comps-extras
23 	xkeyboard-config

A complex kickstart file

The following example is taken from the kickstart configuration file for the CentOS LiveCD

Basic system configuration

Lines 1 to 6 and 11 to 13 are defining basic system configuration.

Line	 
1 	lang en_US.UTF-8
2 	keyboard us
3 	timezone US/Eastern
4 	auth --useshadow --enablemd5
5 	selinux --enforcing
6 	firewall --enabled
11 	xconfig --startxonboot
12 	part / --size 4096
13 	services --enabled=cups,haldaemon,mcstrans,NetworkManager,portmap,restorecond \\
                 --disabled=anacron,auditd,bluetooth,cpuspeed,gpm,hidd,ip6tables,mdmonitor, \\
                            microcode_ctl,netfs,network,nfslock,readahead_early,readahead_later, \\
                            rpcgssd,rpcidmapd,sshd

Yum repositories

Lines 7 to 10 are specifying the yum repositories used for the LiveCD creation.

Line 
7 	repo --name=a-base    --baseurl=http://mirror.centos.org/centos/5/os/$basearch
8 	repo --name=a-updates --baseurl=http://mirror.centos.org/centos/5/updates/$basearch
9 	#repo --name=a-extras  --baseurl=http://mirror.centos.org/centos/5/extras/$basearch
10 	repo --name=a-live    --baseurl=http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live

Package manifest

Lines 16 to 227 contain the package manifest. One or both of two types of package specifier can be used. Individual packages may be installed by giving the name of their RPM (excluding the version and platform information), and groups of packages may be installed by giving their group name. You can also specify package not to be installed by preceding their name with the "-" sign.

Line 
16 	%packages
17 	syslinux
18 	kernel
19 	
20 	@admin-tools
21 	#packages removed from @admin-tools
22 	-sabayon
23 	-system-config-kdump
24 	#@admin-tools <end of package list>
[...]

206 	# For the x86_64 version, one could want to remove i386 and i686 libs
207 	#-*.i386
208 	#-*.i686
209 	
210 	# other usefull packages
211 	Cluster_Administration-en-US
212 	Deployment_Guide-en-US
213 	Global_File_System-en-US
214 	Virtualization-en-US
215 	busybox
216 	mailx
217 	memtest86+
218 	patch
219 	yum-fastestmirror
220 	yum-metadata-parser
221 	
222 	
223 	# LiveCD bits to set up the livecd and be able to install
224 	# Installation from the livecd requires anaconda >= 11.2.0.66
225 	#anaconda
226 	#anaconda-runtime
227 	livecd-installer

Post-installation shell commands

Lines 230 to 557 are specifying a sequence of shell level commands which are executed after the main installation is complete. The beginning of this section is signified by the %post directive. You can take advantage of all of the utilities which have been installed on your LiveCD. The official CentOS LiveCD kickstart file creates a post-installation script under /root/post-install. The script is executed and a log file is created under /root/post-install.log. You will be able to review those files after booting into the LiveCD environment.

Line 
230 	%post
231 	
232 	## locales for the Live CD
233 	PRIMARY_LANGUAGE="en"
234 	PRIMARY_LOCALE="en_US"
235 	SECONDARY_LANGUAGE="fr"
236 	SECONDARY_LOCALE="fr_CA"
237 	
238 	## default LiveCD user
239 	LIVECD_USER="centos"
240 	
241 	########################################################################
242 	# Create a sub-script so the output can be captured
243 	# Must change "$" to "\$" and "`" to "\`" to avoid shell quoting
244 	########################################################################
245 	cat > /root/post-install << EOF_post
246 	#!/bin/bash
247 	
248 	echo ###################################################################
249 	echo ## Creating the centos-live init script
250 	echo ###################################################################
251 	
252 	cat > /etc/rc.d/init.d/centos-live << EOF_initscript
253 	#!/bin/bash
254 	#
255 	# live: Init script for live image
256 	#
257 	# chkconfig: 345 00 99
258 	# description: Init script for live image.
259 	
260 	. /etc/init.d/functions
261 	
262 	if ! strstr "\\\`cat /proc/cmdline\\\`" liveimg || [ "\\\$1" != "start" ] || [ -e /.liveimg-configured ] ; then
263 	    exit 0
264 	fi

[...]

563 	# remove manual pages for unsupported languages
564 	(cd /usr/share/man; \
565 	 if [ \`ls | wc -w\` -gt 16 ]; then \
566 	     mkdir ../temp_dir; \
567 	     mv man* $PRIMARY_LANGUAGE $SECONDARY_LANGUAGE ../temp_dir; \
568 	     rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
569 	     sync; \
570 	 fi)
571 	EOF_post
572 	
573 	/bin/bash -x /root/post-install 2>&1 | tee /root/post-install.log
nochroot option

Lines 576 to 621 are again specifying a sequence of shell level commands which are executed after the main installation is complete. However, these shell commands are run outside the LiveCD environment. This could be used to add some arbitrary file to the resulting LiveCD ISO image for example. The official CentOS LiveCD kickstart file creates a post-installation script under /root/postnochroot-install. The script is executed and a log file is created under /root/postnochroot-install.log. You will be able to review those files on your build host.

Line
576 	%post --nochroot
577 	
578 	########################################################################
579 	# Create a sub-script so the output can be captured
580 	# Must change "$" to "\$" and "`" to "\`" to avoid shell quoting
581 	########################################################################
582 	cat > /root/postnochroot-install << EOF_postnochroot
583 	#!/bin/bash
584 	
585 	# add livecd-iso-to-disk utility on the LiveCD
586 	# only works on x86, x86_64
587 	if [ "\$(uname -i)" = "i386" -o "\$(uname -i)" = "x86_64" ]; then
588 	  if [ ! -d \$LIVE_ROOT/LiveOS ]; then mkdir -p \$LIVE_ROOT/LiveOS ; fi
589 	  cp /usr/bin/livecd-iso-to-disk \$LIVE_ROOT/LiveOS
590 	fi
591 	
592 	# customize boot menu entries
593 	grep -A4 'label linux0'  \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/default.txt
594 	grep -A2 'label memtest' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/memtest.txt
595 	grep -A2 'label local'   \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/localboot.txt

[...]

617 	rm -f \$LIVE_ROOT/isolinux/*.txt
618 	
619 	EOF_postnochroot
620 	
621 	/bin/bash -x /root/postnochroot-install 2>&1 | tee /root/postnochroot-install.log