First of all if you have never seen a kickstart file before and you have installed
a flavor of Redhat Linux on a system go look in the
/root dir you should see a
anaconda-ks.cfg open it up and you will see the parameters you
entered during your install in the kickstart file.
It is a good way to understand by example (providing you can remember the options you selected at boot time).
Below I will give you an example of a kickstart file I use it in my work with remote servers. I chose to use a kickstart install with scripts over imaging software for the Linux installs as this enabled me to use the image on various types of hardware and with the tweak of a script I could greatly customize the installs in the future. Lastly I change the configuration (update packages, settings) using Ansible playbooks after I’ve install the system.
Define the Kickstart file
With this kickstart file, we will do the following actions:
- Define installation source and additional repos (minimal and standart)
- Define Root Password (see here and here to manual create crypted password)
- Install the OS from entirely from the network
- Accept de EULA
- Establish the timezone and enable NTP time synchronization on the host
- Format all drives
- Auto-partition the disk (two parts):
- /boot part - format ext4 part with 1024MiB size
- LVM part on full space of disk with next LV:
- / - 50000 MiB
- /tmp - 30000 MiB
- /var/log - 10000 MiB
- free space - 10000 MiB
- Remove swap part
- Disable kdump
- Skip X Windows packages
- Activate first network device that linked up
Also I like to add post section with commands that allow remote access to the new system using ssh key file:
%post /bin/mkdir /root/.ssh /bin/chmod 700 /root/.ssh /bin/echo -e 'ssh-rsa AAAAB3Nza.....9WhQ== email@example.com' > /root/.ssh/authorized_keys /bin/chown -R root:root /root/.ssh /bin/chmod 0400 /root/.ssh/* %end
Starting the Kickstart Installation
Installing CentOS using kickstart is a 3 step process
- Create the kickstart file (if you don’t already have one)
- Make the kickstart file available to the boot process (e.g. put kickstart file on a web server, e.g. in github like me)
- Access the boot prompt during the Centos installation and then tell the boot prompt where your kickstart file is located.
Specified by the initrd boot parameter
<YOUR_KS_CFG_DESTINATION>should be change to real destination. Press ‘Tab’ button on first boot option to modify initrd boot parameter.
Ultimately you can modify the ISO file and the
isolinux/isolinux.cfg and make it autostart and everything,
but for this post it just wasn’t the right approach. Also you can run PXE server to automate full installation.
That’s all! Automatic Kickstart installations offer a great deal of benefits for system administrators in environments that they have to perform system installations on multiple machines the same time, in a short period of time, without the need to manually interfere with the installation process.
- RedHat - Kickstart Syntax Reference - full list of Kickstart commands and options for RHEL7 (work on RHEL8 also)
- Centos - Kickstart Installations - an instruction on Centos site
- How to Use Kickstart to Install CentOS 7 - useful article describes a using of Kickstart Configurator app to manual create Kickstart file
- Kickstart CentOS 7 installation - good material with information about creation custom ISO file of CentOS
- Automated Installations of Multiple RHEL/CentOS 7 Distributions using PXE Server and Kickstart Files - some instruction about installation RHEL with Kickstart and PXE
- https://github.com/CentOS/Community-Kickstarts - a pack with many different kickstart file examples by CentOS Community