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:
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.
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.
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:
mkdir /tmp/isotest
qemu-img create /tmp/isotest/qemu-hd1.img 4G
Save the following into a script called qemu.sh
!/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
(note how we include -net nic two times to simulate two NICs - you should include this as many times as necessary for your target system)
Now run
./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
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.
part 1 · part 2 · part 4




Comments
First: Thanks for this great tutorial! It works great for me!
On thing to say: In chapter "Running the kickstart" in part 3 it should be "ks.cfg" instead of "kickstart.cfg" :)
Many greets,
daincrediblehol g
I have shared on the message board but it appears as if I'm the only one having to deal with this problem and it's really driving me mad
Many thanks
thank a lot for Jason , this post is great , it helped me a lot
However i'm having a problem at %post -- nochroot , the files never get copied to the HD , was any one able to copy the postinstall folder from the cd ?
if yes please share
thanks all
But I have a problem that it hints"CD was not found in any of your CDROM drivers" and everything has been stopped. I have no idea what should I do next.
I am sure everything seems to be correct before I type `linux ks=cdrom:/ks/ks.cfg`.
Please help! Thanks!
maybe there's a disconnect between the information in the .discinfo file and your repository.
Be sure you follow these steps very carefully:
cd ~/kickstart_build/isolinux
declare -x discinfo=`head -1 .discinfo`
createrepo -u "media://$discinfo" -g ~/kickstart_build/comps.xml .
Notice that the first line of the .discinfo file is pulled into the $discinfo variable and then used in the last command to create the
repository.
If there was any mismatch between the repo and the .discinfo file contents, I would imagine that you might get an error like the one you saw.