Note: this series of articles applies to CentOS 5; for CentOS 6, see this series.
Now that you’ve compiled your RPMs, you need to build a disk image from which to perform the kickstart.
Create the repository
Install createrepo so that you can create a repository. If you’ve copied all the RPMs to ~kickstart_build/all_rpms as suggested earlier, just do this:
1 2 |
cd ~kickstart_build/all_rpms rpm -Uvh createrepo*rpm |
You need to build the repodata for your install disc. These files provide the installer information about the available packages. On your build machine, you should have already copied the repodata/comps.xml file from the CentOS disc 1 to ~/kickstart_build. Use createrepo to build the repository info.
1 2 3 |
cd ~/kickstart_build/isolinux declare -x discinfo=`head -1 .discinfo` createrepo -u "media://$discinfo" -g ~/kickstart_build/comps.xml . |
This will create a repodata directory under ~/kickstart_build/isolinux with the repository data files in it.
Build the ISO
We’re finally ready to build the ISO image that we can burn to CD.
1 2 3 4 |
cd ~/kickstart_build mkisofs -o custom.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/ /usr/lib/anaconda-runtime/implantisomd5 custom.iso |
You should now have an ISO image in custom.iso.
Testing the ISO
Rather than spending the time to burn the CD and perform a physical installation, you can use qemu to test your ISO before you burn it. You may have to go through a few iterations to make sure that your kickstart performs the way you want. It’s much faster to do that without physical media until you’re sure that you’ve got it right.
First create a drive image:
1 2 |
mkdir /tmp/isotest qemu-img create /tmp/isotest/qemu-hd1.img 4G |
Save the following into a script called qemu.sh
1 2 3 4 5 6 7 8 9 10 11 |
#!/bin/bash umount /dev/shm mount -t tmpfs -o size=580m none /dev/shm qemu-system-x86_64 -net nic -net nic -net user -cdrom "$1" -hda /tmp/isotest/qemu-hd1.img -boot d -m 512 </p> (note how we include <span style="font-family: 'courier new', courier;">-net nic</span> two times to simulate two NICs - you should include this as many times as necessary for your target system) Now run <pre>./qemu.sh custom.iso |
to test the ISO. If your target system will have SATA drives, you will need to build an alternate kickstart configuration file that references /dev/hda instead of /dev/sda, because qemu doesn’t support simulated SATA drives. This is when it is helpful to have a ks directory to hold multiple configuration file
Running the kickstart
When the system (virtual or physical) boots up, you’ll see your standard CentOS installation prompt. Rather than just hitting Enter to install, you type
1 |
linux ks=cdrom:/ks/ks.cfg |
If you chose to use some other name for your kickstart config file, replace ks.cfg with the name of your configuration file. You may choose to name your configuration files based on hostname or server class. If you have to use a test configuration file to get around the SATA limitations of qemu, you may call that file test.cfg or something similar.
Your installation should proceed automatically.
Now you have a working custom kickstart disc. To really take advantage of the power of kickstart, you’ll most likely need a custom postinstallation script to configure the system according to your specs. We’ll cover that in the next installment in this series.