Using kickstart Installation
Using kickstart Installation
If you need to install CentOS Linux on many PCs, you need a way to automate the process so that you do not have to respond to the GUI installer prompts for each PC. kickstart is the answer to this need. It's an automated installation method that enables you to install CentOS Linux with very little interaction from you.
The idea behind kickstart is to create a text file with all the installation options and then "kick start" the installation by booting and then providing the kickstart file as input.
Starting a kickstart Installation
Setting aside for the moment how to prepare a kickstart file, I want to briefly explain how you can start a kickstart installation. The common use of kickstart installation is to place the CentOS Linux ISO images on a server on the network and then perform kickstart installations at all the PCs. Let's assume that you have the ISO images on a Web server and you want to install over the network using the HTTP installation method, but do this under the control of a kickstart file. Here's what you would do:
-
Prepare a boot disk with the
bootdisk.img
file (located in the images directory of the first CentOS Linux CD-ROM). -
Prepare a network driver disk with the
drvnet.img
file. -
Place the ISO images and the kickstart file on the Web server and make note of the directory where the kickstart file is located.
-
Boot the PC using the boot disk. At the boot prompt, type the following command:
linux ks=http://<server>/<pathname of kickstart file>
where <
server
> stands for the name of the Web server and <pathname of kickstart file
> is the complete pathname of the kickstart file. Thus, if the server is mycompany.com and the kickstart file's pathname is/redhat8/ks.cfg
, then you type the following at the boot prompt:linux ks=http://mycompany.com/redhat8/ks.cfg
After that the installation should proceed under the control of the kickstart file.
If the kickstart file is on an NFS server, all you have to do is specify the kickstart file appropriately. The kickstart syntax for NFS is
linux ks=nfs:<server>:/<path>
Thus, if the NFS server is someserver.com
and the location of the kickstart file is /somedir/ks.cfg
, then you type the following command at the boot prompt:
linux ks=nfs:someserver.com:/somedir/ks.cfg
You can also place a kickstart file named ks.cfg on a floppy (type mcopy ks.cfg a: to copy the file to a floppy), and then install it with the following command at the boot prompt:
linux ks=floppy
You can also use a very simple form of the kickstart installation command that looks like this:
linux ks
In this case, the installation program configures the Ethernet card using DHCP and then uses the bootServer
item from the DHCP response as the NFS server from which to get the kickstart file. The name and location of the kickstart file depends on the bootfile specified by DHCP. If the DHCP server does not specify a bootfile, the installler tries to read the file /kickstart/A.B.C.D-kickstart
, where A.B.C.D
is the numeric IP address of the PC on which you are installing CentOS Linux.
Preparing the kickstart File
One way to get a kickstart file is to perform the installation on one PC. The Red Hat installer saves the installation options in the /root/anaconda-ks.cfg
kickstart file. You can then use this kickstart file to repeat the installation on other PCs. You can also use this kickstart file as a starting point and edit it to create a custom kickstart file suitable for your situation.
Here's a typical anaconda-generated kickstart file:
# Kickstart file automatically generated by anaconda. install lang en_US.UTF-8 langsupport --default en_US.UTF-8 en_US.UTF-8 keyboard us mouse generic3ps/2 --device psaux xconfig --card "nVidia GeForce 2 Go" --videoram 16384 --hsync 31.5-48.5 --vsync 40-70 --resolution 1024x768 --depth 24 --startxonboot --defaultdesktop gnome network --device eth0 --bootproto dhcp rootpw --iscrypted $1$7oGAOtge$Q7PC0e2sIRSwRouqxlyMS. firewall --disabled authconfig --enableshadow --enablemd5 timezone America/New_York bootloader --location=mbr ... other kickstart options deleted ... %packages @ Administration Tools @ GNOME Desktop Environment @ Office/Productivity @ Printing Support .... other package groups... @ X Window System gnome-audio tk ... other individual packages... xmms firstboot %post
As you can see, the file starts with a long list of kickstart options that essentially mirrors the installation steps that you normally go through when you install CentOS Linux interactively. After the kickstart options comes a %packages
section that lists the package groups and individual packages to install. Finally, you see a %post
section that contains any commands to execute after the installation is complete. For example, you could add commands in the %post
section to add one or more user accounts.
As this example illustrates, a kickstart file has the following sections, in the exact order shown:
-
Command section-This section lists all the kickstart options that control various aspects of the installation
-
%packages section-This section lists the package groups (with names that have an @ prefix) and individual package names.
-
%pre and %post sections-These two sections are optional, and they can appear in any order.
The command section of the kickstart file contains, at minimum, all the required options shown in Table 2-4. That table shows all the kickstart options and briefly describes each option.
Option |
Optional (O) or Required (R) |
Description |
---|---|---|
|
O |
Similar to interactive, except that it goes to the next screen for you. It is used mostly for debugging. |
|
R |
Specifies the authentication options. Use one or more of following arguments after this option: |
- | ||
- | ||
- | ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
R |
Specifies where the boot loader is installed and, optionally, which boot loader to install. Use one or more of following arguments after this option: |
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
O |
Removes partitions from the system before creating new partitions. Use one or more of following arguments after this option: |
| ||
-all (erases all existing partitions) | ||
| ||
| ||
|
O |
Instructs installer to load extra device driver modules. Use the following arguments: |
<type> (either | ||
< | ||
| ||
|
O |
Probes the PCI bus for devices and loads modules for all the devices found (assuming that a module is available for the device) |
|
O |
Instructs the installer to look for driver disks in the specified disk partition. Use the following arguments: |
< | ||
| ||
|
O |
Configures the firewall based on the arguments: |
< | ||
| ||
< | ||
| ||
|
O |
Indicates that you want to do a fresh install. Specify the install method with one of the following arguments: |
| ||
| ||
| ||
| ||
| ||
|
O |
Allows you to view and modify options as kickstart install progresses |
|
R |
Sets the keyboard type. Here is the list of available keyboards on i386, Itanium, and Alpha machines: |
|
R |
Sets the language to use during installation. Valid language codes are |
|
R |
Sets the languages to install on the system. Use the same language codes as the ones for the |
| ||
|
O |
Creates a logical volume for Logical Volume Management (LVM). Provide the following arguments: |
< | ||
| ||
| ||
| ||
|
R |
Specifies the mouse type and configures it. Use the following arguments: |
| ||
| ||
< | ||
|
O |
Configures the local area network information. For installations over network, the installation uses the first Ethernet card ( |
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
R |
Creates a partition on the hard drive. Use the following arguments to specify details: |
< | ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
O |
Creates a software RAID device. Use the following arguments: |
< | ||
| ||
| ||
| ||
| ||
| ||
O |
Reboots after the installation is complete | |
|
R |
Sets the system's root password. Use the following arguments: |
| ||
< | ||
|
O |
Skips configuration of X Window System. |
|
O |
Performs the installation in text mode (instead of the default graphical mode). |
|
R |
Sets the system time zone. Use the following arguments: |
| ||
< | ||
|
O |
Upgrades an existing system rather than installing a fresh system |
|
O |
Configures the X Window System. Use the following arguments: |
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
O |
Creates a Logical Volume Management (LVM) group. Use following arguments: |
< | ||
< | ||
|
O |
Initializes any invalid partition tables found on disks. Use the following argument: |
| ||
|
O |
Includes the content of another file into this kickstart file. Use the following arguments: |
< |
The package group names listed in the %package
section are defined in the RedHat/base/comps.xml
file on the first CentOS Linux CD-ROM. The comps.xml
file uses XML to define the package database. Each package group contains one or more packages. The comps.xml
file also defines the dependencies for each package-the other packages that a package needs in order to work properly.
The %pre
section includes commands to be executed immediately after the kickstart file has been processed but before any installation steps are performed. In the %pre
section, you can place a shell script to perform any preparatory tasks that have to be performed before installation can begin.
The %post
section contains the commands to be executed after installation complete. In this section, you can place commands to turn services on or off and add user accounts.