10.4. Installing with KickstartIn a normal Fedora Core installation, Anaconda asks a number of questions before beginning the actual installation procedure, which then runs without any user intervention (except for changing CDs, if that is the chosen installation method). Kickstart is a Fedora installation option that uses a text file to supply basic configuration information so that Anaconda can skip all of the questions normally asked during installation. 10.4.1. How Do I Do That?To use Kickstart, you must create a Kickstart file using any regular text editor. A Kickstart file contains a number of options, one per line, with arguments. These options are required:
To encrypt a password for the bootloader and root access, use the openssl command: $ openssl passwd -1 -salt "RaNDoMjuNk" "MySecretPassword" $1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1 Replace RaNDoMjuNK with any garbage characters you want to use, and MySecretPassword with the desired password. Cut and paste the result into the Kickstart file as the encrypted password. Here is a basic configuration using these options: auth --enableshadow --enablemd5 bootloader --location=mbr --md5pass=$1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1 lang en_US keyboard us rootpw --iscrypted $1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1 timezone America/Toronto Next, specify the installation source and networking:
Note that the directory specified for the url or nfs options must contain the fedora directory of the installation tree; in other words, it must be equivalent to the root directory of the Fedora Core CD or DVD. To specify HTTP as the installation method on a system with two network interfacesone configured with DHCP and one with a static IPuse a configuration like this: url --url=http://192.168.1.2/fc6/ network --bootproto=dhcp --device eth0 network --bootproto=static --device eth1 \ --ip 10.2.97.33 --netmask=255.255.255.0
If you are using Kickstart to perform an upgrade instead of an installation, use the upgrade option. Otherwise, use these options to lay out the storage:
For example, if you had a system with two 200 GB disks (as the master IDE/ATA drives on the primary and secondary disk controllers) with RAID 1 and LVM (see Lab 6.2, "Managing RAID"), the storage layout options would look like this: # General partitioning options clearpart --all --initlabel --drives=hda,hdc zerombr yes # Partitions # Two IDE disk drives, hda and hdc part raid.01 --size 100 --ondrive=hda part raid.02 --size 40000 --ondrive=hda part raid.03 --size 40000 --ondrive=hda part raid.04 --size 40000 --ondrive=hda part raid.05 --size 40000 --ondrive=hda part raid.06 --size 1 --ondrive=hda --grow part raid.07 --size 100 --ondrive=hdc part raid.08 --size 40000 --ondrive=hdc part raid.09 --size 40000 --ondrive=hdc part raid.10 --size 40000 --ondrive=hdc part raid.11 --size 40000 --ondrive=hdc part raid.12 --size 1 --ondrive=hdc --grow # RAID arrays # Six RAID arrays, all RAID 1: # - one is 100 MB /boot array # - five are 40GB PV arrays # (4 * 40000 MB, remaining space in last array) raid /boot --device md0 --level=RAID1 raid.01 raid.07 --fstype ext3 raid pv.01 --device md1 --level=RAID1 raid.02 raid.08 raid pv.02 --device md2 --level=RAID1 raid.03 raid.09 raid pv.03 --device md3 --level=RAID1 raid.04 raid.10 raid pv.04 --device md4 --level=RAID1 raid.05 raid.11 raid pv.05 --device md5 --level=RAID1 raid.06 raid.12 # Volume Group 'main' volgroup main pv.01 pv.02 pv.03 pv.04 pv.05 # LVs for root (10GB), /home (35GB), /var (35GB), and swap (1GB), # leaving about 20 GB available for snapshots and future expansion # of the LVs logvol swap --vgname=main --size=1024 --name=swap logvol / --vgname=main --size=10000 --name=root --fstype=ext3 logvol /home --vgname=main --size=35000 --name=home --fstype=ext3 logvol /var --vgname=main --size=35000 --name=var --fstype=ext3 You can now specify the user interface mode during installation:
You can also include instructions on how the final user interface is to be configured:
Putting these options together for a text based, hands-off installation configured so that the installed system will start up with a graphical login prompt (1024x768 resolution, 16-million-color display), use: text xconfig --startxonboot --depth=24 --resolution=1024x768 Next comes security:
This is a typical configuration: firewall --enabled --port=5900:tcp --ssh --http --smtp
You can now specify what should happen after the installation is complete:
To shut the system down and allow for reconfiguration when the system is first turned on, use: firstboot --reconfig poweroff At the very end of the Kickstart file, place the option %packages, followed by a list of packages to be installed, one per line. To see the available package names, look in the Fedora directory of the installation tree (e.g., the installation DVD or network installation server). Instead of selecting packages individually, you can choose groups of packages as shown in Table 10-3.
Use * to select all available packages (dependencies and conflicts permitting). On the other extreme, use the special package group @core to install a very minimal, text-based system (almost too small to be usable but a good starting point for very compact systems) or @base to install a small text-based system with enough basic software to be useful. To exclude a package, prepend a minus sign: -hdparm For example, if you wanted GNOME, office applications, Samba, printing capability, support for Russian, the GIMP graphics editor, and the Tomboy note program, place these lines at the end of the Kickstart file: %packages @gnome-desktop @office @smb-server @printing @russian-support gimp tomboy Putting this all together, we get this Kickstart file: auth --enableshadow --enablemd5 bootloader --location=mbr --md5pass=$1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1 lang en_US keyboard us rootpw --iscrypted $1$RaNDoMju$OS0p7cTCbvCJ2ITUfcovM1 timezone America/Torontourl --url=http://192.168.1.2/fc6/ url --url=http://192.168.1.2/fc6/ network --bootproto=dhcp --device eth0 network --bootproto=static --device eth1 \ --ip 10.2.97.33 --netmask=255.255.255.0 # General partitioning options clearpart --all --initlabel zerombr yes # Partitions # Two IDE disk drives, hda and hdc part raid.01 --size 100 --ondrive=hda part raid.02 --size 40000 --ondrive=hda part raid.03 --size 40000 --ondrive=hda part raid.04 --size 40000 --ondrive=hda part raid.05 --size 40000 --ondrive=hda part raid.06 --size 1 --ondrive=hda --grow part raid.07 --size 100 --ondrive=hdc part raid.08 --size 40000 --ondrive=hdc part raid.09 --size 40000 --ondrive=hdc part raid.10 --size 40000 --ondrive=hdc part raid.11 --size 40000 --ondrive=hdc part raid.12 --size 1 --ondrive=hdc --grow # RAID arrays # Six RAID arrays, all RAID 1: # - one is 100 MB /boot array # - five are 40GB PV arrays # (4 * 4000 MB, remaining space in last array) raid /boot --device md0 --level=RAID1 raid.01 raid.07 --fstype ext3 raid pv.01 --device md1 --level=RAID1 raid.02 raid.08 raid pv.02 --device md2 --level=RAID1 raid.03 raid.09 raid pv.03 --device md3 --level=RAID1 raid.04 raid.10 raid pv.04 --device md4 --level=RAID1 raid.05 raid.11 raid pv.05 --device md5 --level=RAID1 raid.06 raid.12 # Volume Group 'main' volgroup main pv.01 pv.02 pv.03 pv.04 pv.05 # LVs for root (10GB), /home (35GB), /var (35GB), and swap (1GB), # leaving about 20 GB available for snapshots and future expansion # of the LVs logvol swap --vgname=main --size=1024 --name=swap logvol / --vgname=main --size=10000 --name=root --fstype=ext3 logvol /home --vgname=main --size=35000 --name=home --fstype=ext3 logvol /var --vgname=main --size=35000 --name=var --fstype=ext3 text xconfig --startxonboot --depth=24 --resolution=1024x768 firewall --enabled --port=5900:tcp --ssh --http --smtp firstboot --reconfig poweroff %packages @gnome-desktop @office @smb-server @printing @russian-support gimp tomboy 10.4.1.1. Using a Kickstart fileTo use a Kickstart file, make it accessible to the installation target system by placing it on an HTTP, FTP, or NFS server, or put it on a floppy disk. To use a Kickstart file on floppy disk, add ks=floppy to the boot string encountered when booting from a USB key or optical disc: : linux ks=floppy It is assumed that the Kickstart file is named ks.cfg, that it is in the root directory of the floppy disk, and that the floppy disk is formatted with an MS-DOS (VFAT) or ext2 filesystem. To make the Kickstart file available through the web server on a Fedora Core system, use these commands (assuming that the file is named ks.cfg and is in the current directory): # mkdir -p /var/www/kickstart # cp ks.cfg /var/www/kickstart You can then access the Kickstart file by URL at the installation boot prompt: : linux ks=http://192.168.1.2/kickstart/ks.cfg (Replace 192.168.1.2 with the actual address of your server.) However, when booting from a PXE boot server, no boot prompt is provided. Instead, you must configure the Kickstart file by entering the URL into the system-config-netboot window for a particular IP address or range (Figure 10-20) or using the -K argument to the pxeboot command: # pxeboot -a -O fc6 192.168.1 -K http://192.168.1.2/kickstart/ks.cfg 10.4.2. How Does It Work?Fedora's Anaconda installer is written in Python and uses a library called the Red Hat Python Library, or rhpl. Before commencing the installation process, Anaconda must load the data structures that control the installation. These data structures can be filled with data from user input or from the Kickstart file. 10.4.3. What About...10.4.3.1. ...creating a Kickstart file using a graphical tool?Fedora Core provides the system-config-kickstart utility for graphically editing a Kickstart file. Unfortunately, the version of system-config-kickstart shipped with Fedora Core 6 has some show-stopping bugs that cause it to create defective Kickstart files, and it is not able to configure LVM systems. However, you can use it to create a rough Kickstart file to use as a starting point for further customization. 10.4.3.2. ...creating a Kickstart file that dynamically adjusts according to properties of the installation target?Kickstart files can include a script that is run before installation, and the output of that script can be included into the Kickstart configuration. For example, to configure swapspace to be double the memory size, you can add this script to the Kickstart file: %pre # Calculate twice the size of the installed memory, in MB MEM=$(cat /proc/meminfo|sed -n "s/MemTotal: *\([0-9]\+\) kB/\1/p") SIZE=$(( $MEM * 2 / 1024 )) # Create the file /tmp/swap.cfg echo "logvol swap --vgname=main --size=$SIZE --name=swap" >/tmp/swap.cfg The %pre option identifies this part of the file as a preinstallation script. Place this script at the end of the Kickstart file; it will produce the file /tmp/swap.cfg containing the appropriate logvol line for the swap partition. You can then replace the swap partition line in the Kickstart file with an option that refers to the /tmp/swap.cfg file using %include: # LVs for root (10GB), /home (35GB), /var (35GB), and swap (RAM * 2), # leaving about 20 GB available for snapshots and future expansion # of the LVs. %include /tmp/swap.cfg logvol / --vgname=main --size=10000 --name=root --fstype=ext3 logvol /home --vgname=main --size=35000 --name=home --fstype=ext3 logvol /var --vgname=main --size=35000 --name=var --fstype=ext3
10.4.3.3. ...performing customization after installation?The Kickstart file can also include a script that is run after installation, using the %post option. Here is an example: % post # Add aliases to /etc/bashrc: echo "alias l='ls -l'" >>/etc/bashrc echo "alias cls='clear'" >>/etc/bashrc # Change the login welcome message for text consoles echo "Welcome to Fedora Core!" >/etc/issue # Place a copy of acceptable-use-policy.txt # in /etc/skel so that it will be copied to each # new user's home diretory. cd /etc/skel wget http://192.168.1.2/text/acceptable-use-policy.txt # Configure httpd to start automatically on boot /sbin/chkconfig httpd on
10.4.3.4. ...installing a system with the same configuration as another, previously installed system?Whenever you install a system, the configuration used for that system is written into the file /root/anaconda-ks.cfg. This is a standard Kickstart file with the disk layout commented out (every line has a # prepended). If you uncomment the disk layout and then use this as the Kickstart file for another system, it will produce an identical configuration (note that the hardware must be sufficiently similar for this to work). 10.4.4. Where Can I Learn More?
|