While installing CentOS 7 manually using the graphical installer utility is fine on a single server, doing so on a multiple number of systems can be tedious. Kickstart files can automate the installation process of a server system and here we will show how this can be done. They are simple text based configuration files which provide detailed and exact instructions on how the target system should be set up and installed (for example, which keyboard layout or additional software packages to install).
To successfully complete this recipe, you will need access to an already installed CentOS 7 system to retrieve the kickstart configuration file we want to work with and use for automated installation. On this pre-installed CentOS server, you also need a working Internet connection to download additional software.
Next, we will need to download and create installation media for the DVD or the Everything image (download the latest CentOS-7-x86_64-DVD-XXXX.iso
or CentOS-7-x86_64-Everything-XXXX.iso
file), instead of the minimal iso file shown in another recipe in this chapter. Then you need another USB device which must be read and writable on Linux systems (formatted as FAT16, FAT32, EXT2, EXT3, EXT4, or XFS filesystem).
For this recipe to work, we first need physical access to an existing kickstart file from another finished CentOS 7 installation, which we will use as a template for a new CentOS 7 installation.
ls -l /root/anaconda-ks.cfg
fdisk -l
/dev/sdX,
where X
is an alphabetical character, such as b
, c
, d
, e
, … and so on. If you cannot find the right device name for your USB media using the fdisk
command, try the following trick: run fdisk -l
twice - first with plugged-out and then with plugged-in USB device and compare how the second output changed - it has one device name more than the first output: your device name of interest !mkdir /mnt/kickstart-usb
/dev/sdc1
(change this as required):mount /dev/sdc1 /mnt/kickstart-usb
cp /root/anaconda-ks.cfg /mnt/kickstart-usb
yum install nano
):nano /mnt/kickstart-usb/anaconda-ks.cfg
<your_hostname>
will be the name of the hostname you gave during installation e.g. minimal.home
):network --hostname=<your_hostname>
<your_hostname>
string to give it a new unique hostname. For example, add a -2
to the end of any existing name, as shown next:network --hostname=minimal-2.home
%packages.
Append the following lines right below it (you can further customize this and provide additional packages that you want to install automatically):mariadb-server httpd rsync net-tools
yum install system-config-kickstart
ksvalidator
program, which is included in the package we just installed:ksvalidator /mnt/kickstart-usb/anaconda-ks.cfg
config
file is error-free, unmount the USB stick now by using the following commands:cd umount /mnt/kickstart-usb
boot: prompt
./dev/sdc1
(change this as required), and press the Return key to start the kickstart installation process:linux ks=hd:sdc1:/anaconda-ks.cfg
If you cannot find out the right device and partition name of the USB stick, you have to start the target system in rescue mode (refer to the Troubleshooting the system in rescue mode recipe) to identify the right device name and partition number by comparing its size, partitions, and identified filesystems with the specifications of your stick.
In this recipe, you have seen that every server running a CentOS 7 installation keeps the kickstart file in its root directory, which contains detailed information on how the system had been set up during the installation. The kickstart files can be used to automate the installations of multiple systems with the same configuration. This can save a lot of time doing repetitive work as no user interaction during installation is needed. Also, we can use this method if the target machines don't meet the minimum requirement in RAM for graphical based installations but when needed other features the text mode installer does not provide such as custom partitioning of the system. Kickstart configuration files are simple plain text files which can be created manually from scratch. Because there are quite a number of different commands available to construct your system using the kickstart syntax, we used an existing file as a template and customized it to fit our needs, instead of starting out completely new. We did not use the minimal installation image to drive our kickstart installation because we installed some extra packages not included on the minimal ISO file, such as the Apache webserver.