I have been setting up machines with Kickstart on CentOS and I am unsure about the differences between the %pre
and %post
sections of the kickstart .cfg
file.
The CentOS Documentation for the Pre-Installation Script states:
You can add commands to run on the system immediately after the ks.cfg has been parsed.
While the section for the Post-Installation Script states:
You have the option of adding commands to run on the system once the installation is complete.
After also reading this question, i notice that the %pre
section does not seem to have access to the file system in some way.
My question(s) are:
- What are the differences between
%pre
and%post
sections of a kickstart script in CentOS? - Is the
%pre
section run concurrently with the kickstart script (after parsing)? - Is there persistent storage available during the
%pre
section of the kickstart script?
Best Answer
The
%pre
section runs prior to when anaconda evaluates the rest of the kickstart file, after the second stage of the installer has started. This means that you can create files in%pre
that can be included with a%include /tmp/somefile
in the kickstart configuration.%post
runs after package installation and bootloader setup has completed.The RHEL documentation says the %pre is executed after the kickstart is parsed, but can dynamically create additional content to the kickstart through %include statements. https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-preinstallconfig.html
Typically, you use a writable /tmp directory in
%pre
, which is not persistent to the resulting OS. It's just a ramdisk.%post
runs chrooted into the new install root, or it can run in the root of anaconda (with%post --nochroot
), where you can access the files you might have created/saved during%pre
.