Creating a Basic Kickstart File for Automated Linux Installations

kickstart linux Aug 22, 2023

Similar to how Windows Answer Files help in automating installations of the Windows OS, kickstart files help in automating installations of some Linux distributions.  Automating Linux installations can save valuable time and ensure consistency across multiple systems.  In my opinion, kickstart files are much easier to read (plain text file) when compared to Windows Answer Files (XML file).  Let's take a look at what a kickstart file is, the benefits of using one, and creating a basic one.  We'll end with a demo showing how to install Red Hat Enterprise Linux 9.2 using a kickstart file on VMware Workstation Pro.  

What is a Kickstart File?

A Kickstart file is a configuration file used by various Linux distributions to automate the installation process.  It contains instructions and settings that replace the need for manual input during installation.  You can create it using a simple text editor or by copying the anaconda-ks.cfg, located in the /root/ direction, from an existing Linux installation (RHEL / Centos /  etc).  If you have a Red Hat Customer Portal account, you can also use the Kickstart Configuration Tool.  However, this tool does not currently support any advanced partitioning.

Linux Distributions Supporting Kickstart Files:

Not all Linux distributions support the use of Kickstart files.  Below is a list of the distros that I'm currently aware of:

  • Red Hat Enterprise Linux (RHEL)
  • CentOS
  • Fedora
  • Oracle Linux

Benefits of Using Kickstart:

  • Eliminate manual installation steps.
  • Reduce human errors and ensure consistency
  • Accelerate the deployment of new installations.

Basic Syntax and Structure:

Kickstart files consist of multiple sections, each representing a different aspect of the installation process.  These sections must be specified in the correct order; Command section, %packages section, and the %pre and %post sections (these two sections are not required).  If you have a Red Hat Customer Portal account (sign up for free here), check out the Kickstart Options documentation for a full list of options.

  • Keyboard and Language Configuration - Specify the keyboard layout and language.
  • Network Configuration - Define networking settings, including hostname, IP address, and DNS.
  • Installation Source - Indicate the installation source, such as local media or network repository.
  • Partitioning - Define the disk layout and partitions.  You can choose automatic or manual partitioning.
  • Package Selection - Specify which packages and groups to install.  Avoid using * in the %packages section.  This would install every available package.  Environments can be specified using the @^ symbol, followed by the environment to be installed.  For example, @^graphical-server-environment will install the Server with GUI environment.  You can use the Kickstart Configuration Tool to help build the Kickstart config file with basic options.  
  • Authentication - Set the root password and optionally configure user accounts.
  • Post-Installation Scripts - Execute scripts after the installation to perform additional configurations.

Making a Kickstart file available during installation:

There are multiple methods of making the Kickstart file available during installation (see here for additional details);

  • HTTP
  • HTTPS
  • FTP
  • NFS
  • TFTP
  • Local volume (USB stick, ISO, etc)
    • To enable the automatic loading of the Kickstart file, the volume label must be named OEMDRV.  We'll use this method in our demo to avoid setting up a HTTP web server.  However, for multiple simultaneous installations, a centralized location for the Kickstart file would be needed.

Creating a Basic Kickstart File:

  1. Start with the '#version' directive to specify the Kickstart version.
  2. Configure language and keyboard settings.
  3. Configure the timezone.
  4. Set the root password.
  5. Use the text installation method vs graphical.
  6. Install from cdrom.
  7. Clear the Master Boot Record.
  8. Remove all existing partitions.
  9. Initialize the disk label
  10. Use automatic partitioning
  11. Install the Server with GUI environment.  This will not start the GUI by default.  If you want the GUI to load automatically, run "systemctl set-default graphical.target" after installation.

Demo:

 

As always, I like to show this process in action.  You can check out the demo over on YouTube.  We build the Kickstart file, using the Kickstart Generator tool, write the file to an ISO, and then install RHEL as a guest VM on VMware Workstation Pro.  Below are a few prerequisites if you want to follow along.

Conclusion:

Kickstart files serve as the foundation for automating Linux installations, offering streamlined deployment and consistent system setups. As you advance, explore advanced options, integrate with automation tools, and customize configurations for organization-specific needs. Experiment in a lab environment, leverage documentation and replicate real-world scenarios for practical learning. Kickstart files empower you to deploy systems effectively, making them an essential tool in your automation toolkit.

Additional Resources:

Elevate your IT automation skills and career with courses from AutomateSQL!

Coming soon.