ONLamp.com
oreilly.comSafari Books Online.Conferences.

advertisement


Hands-Off Fedora Installs with Kickstart
Pages: 1, 2

Time Zone

Set the machine's time zone with the timezone directive:

timezone America/Chicago

Valid time zones are in the TZ column of the file /usr/share/zoneinfo/zone.tab.

Boot Loader

The bootloader directive sets the location of the GRUB boot loader. The sample ks.cfg places it in the master boot record (MBR):

bootloader --location=mbr

If you don't want a boot loader, specify --location=none. Remove an old boot loader from the MBR with the separate zerombr directive.

Disks

Disk setup is the most complex part of a ks.cfg because there are so many machine- and environment-dependent choices. Note that the sample ks.cfg clears existing partitions on the target machine, so be sure to backup any valuable data.

clearpart removes disk partitions.

clearpart --all --drives=sda --initlabel 

clearpart can remove just Linux partitions (--linux) or all existing partitions (--all). It removes partitions from all drives unless you've added the --drives flag. The --initlabel flag works for previously unused disks or disks with foreign partition schemes: it clears out the old partitions and sets up a scheme that Linux can understand.

Omit clearpart to preserve existing partition boundaries.

part sets up partitions. The sample ks.cfg uses a simple two-partition layout and has a separate swap partition:

part /boot --fstype ext3 --size=100 --ondisk=sda --asprimary
part / --fstype ext3 --size=1024 --grow --ondisk=sda --asprimary
part swap --size=128 --grow --size=256 --ondisk=sda --asprimary

The first parameter specifies the mount point, here /boot, /, and swap. (Linux doesn't really mount swap space, but that's a minor technicality.) Set the file-system type with the --fstype flag. The sample uses ext3. Other options include ext2 and vfat (aka Windows). Swap doesn't use a file-system type.

Specify a partition's size in megabytes using the --size flag. Specify the partition's physical disk with the optional --ondisk flag. Mark your primary partitions with --asprimary.

part's --onpart and --noformat flags preserve existing partitions between Kickstart installs. For example, the following would mount the preexisting hda7 as /home:

part /home --fstype ext3 --size 1024 --onpart hda7 --noformat 

Note that this won't shuffle data to another part of the disk if other partition sizes change; it simply tells Kickstart to leave hda7's partition boundaries intact and to skip creating a new file system there using mkfs.

The following is a simple one-disk LVM setup:

part /boot --fstype ext3 --size=75 --asprimary
part pv.00 --size=1 --grow --asprimary

volgroup vgroot pv.00
logvol / --name=root.fs --vgname=vgroot --size=1024
logvol swap --name=swap.vol --vgname=vgroot --size=256

The second part directive sets up a partition as an LVM physical volume (PV). The --grow flag grows this partition to the maximum allowable size, so that you needn't know the disk's size ahead of time. part still requires a size, though, so it uses a bogus PV partition size of 1MB.

logvol is LVM's part equivalent: it accepts the logical volume's mount point and size, in addition to the volume group to which it belongs. logvol's --name flag names the volume.

Note that the generated /root/anaconda-ks.cfg on the target host has a commented-out disk layout.

Rebooting

The reboot directive forces the target host to reboot when the installation completes. Don't forget to remove the installation media, lest the machine reboot right back into the installer.

Package Selection

The %packages directive specifies which RPMs to install on the target host. You may select packages individually or en masse as groups. To specify a group, prefix the name with the @ symbol and a space. Precede a name with a minus symbol (-) to exclude that package from the group.

%packages
@ dialup
kernel
grub
e2fsprogs

The Fedora/base/comps.xml file, from the install media, defines package groups. I'll describe this file in greater detail in a future article.

Kickstart installs packages in addition to those you select in order to resolve dependencies. Use %packages's --ignoredeps flag to ignore package dependencies.

Package selection is another area in which it is easiest to perform a manual installation once, then mine the resultant /root/anaconda-ks.cfg file for information.

Build the Target Machine: Run the Kickstart

The hard work is done. Now boot the target machine from the Fedora media. At the boot: prompt, enter:

linux ks=http://build-server/kickstart/ks.cfg

You will receive an error if the boot media does not match the version of Fedora you're trying to install.

Unless you have DHCP available on the target machine's network, the installation will pause for you to enter its IP configuration. This is fine for small deployments and experiments, but a full, hands-off Kickstart infrastructure calls for DHCP or bootp.

The installation will also pause for input if any required directives are missing from ks.cfg.

Troubleshooting a Failed Install

The installer's error reporting can be cryptic. Messages refer to lines in Anaconda's underlying Python scripts, not your ks.cfg.

Include the interactive directive to step through the installation using values from ks.cfg as the defaults. You cannot test the root password this way, though; you must enter that manually.

Going Beyond

My Kickstart R&D has certainly paid off: I no longer have to click through the full Fedora installer and I can grab a tea while Kickstart does the hard work. Hopefully, this article will help jump-start your own Kickstart projects.

There is a lot more to Kickstart than what I have described here. It supports several customization points, including home-grown RPMs and pre-/post-install scripts. I'll cover these and more in a future article.

Resources

Ethan would like to thank Scott Wheeler for reviewing this article.

Q Ethan McCallum grew from curious child to curious adult, turning his passion for technology into a career.


Return to LinuxDevCenter.com.



Sponsored by: