Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




NOTE: CentOS Enterprise Linux 5 is built from the Red Hat Enterprise Linux source code. Other than logo and name changes CentOS Enterprise Linux 5 is compatible with the equivalent Red Hat version. This document applies equally to both Red Hat and CentOS Enterprise Linux 5.

28.7. Post-installation Script

You have the option of adding commands to run on the system once the installation is complete. This section must be at the end of the kickstart file and must start with the %post command. This section is useful for functions such as installing additional software and configuring an additional nameserver.


If you configured the network with static IP information, including a nameserver, you can access the network and resolve IP addresses in the %post section. If you configured the network for DHCP, the /etc/resolv.conf file has not been completed when the installation executes the %post section. You can access the network, but you can not resolve IP addresses. Thus, if you are using DHCP, you must specify IP addresses in the %post section.


The post-install script is run in a chroot environment; therefore, performing tasks such as copying scripts or RPMs from the installation media do not work.


Allows you to specify commands that you would like to run outside of the chroot environment.

The following example copies the file /etc/resolv.conf to the file system that was just installed.

%post --nochroot cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
--interpreter /usr/bin/python

Allows you to specify a different scripting language, such as Python. Replace /usr/bin/python with the scripting language of your choice.

28.7.1. Examples

Register the system to a Red Hat Network Satellite:

          %post ( # Note that in this example we run the entire %post section as a subshell for logging. wget -O- | /bin/bash /usr/sbin/rhnreg_ks --activationkey=<activationkey> # End the subshell and capture any output to a post-install log file. ) 1>/root/post_install.log 2>&1

Run a script named runme from an NFS share:

          mkdir /mnt/temp mount -o nolock /mnt/temp open -s -w -- /mnt/temp/runme umount /mnt/temp


NFS file locking is not supported while in kickstart mode, therefore -o nolock is required when mounting an NFS mount.

  Published under the terms of the GNU General Public License Design by Interspire