tech on the net

Linux: Updating and Rebuilding RedHat 9 Installation CDs

Question: Redhat 9 has been out for a while now and there are quite a few updates available for it. Each time I build a new system I have to download and install all of these updates. Is there any way I can create new installation CDs with the updates already included?

Answer: Yes, RedHat Linux comes with all of the tools you need to accomplish this. We've broken the procedure down into 6 steps below. (We have used this procedure to fix an installation problem with Redhat 9 and the DAC960 RAID controller.)

Step 1: Preparation

This procedure is not for the novice. If you find this document confusing, it would be best to find an experienced Linux user to help you through it.

To start, a proper build environment is required.

You'll need a computer with Redhat 9 installed on it and 10GB of free hard disk space.

The following packages will also need to be installed from the installation CD:

anaconda-9.0-4
anaconda-images-9.0-3
anaconda-help-9.0-2
anaconda-runtime-9.0-4

You'll need to be the super user (root) to proceed from here. Commands are assumed to be executed from a bash shell.

Find a location on your hard disk which has the necessary space and type the following commands:

export PYTHONPATH=/usr/lib/anaconda
export PATH="$PATH:/usr/lib/anaconda-runtime"
export RHBASE='pwd'
mkdir -p $RHBASE/redhat/i386
cd $RHBASE/redhat

These commands will create a scratchpad area to work from and setup some convenience environment variables.

Next, download all six of the installation ISOs from RedHat's site into the $RHBASE/redhat directory.

Once the ISO files are downloaded, we will need to extract their contents into our working directory. You can do so with the following commands.

For each of the three installation CDs, do the following:

mount -o loop shrike-i386-disc1.iso /mnt ; cd /mnt ; tar -cf - * | ( cd $RHBASE/redhat/i386/ ; tar -xpf - ) ; cd $RHBASE/redhat ; umount /mnt
mount -o loop shrike-i386-disc2.iso /mnt ; cd /mnt ; tar -cf - * | ( cd $RHBASE/redhat/i386/ ; tar -xpf - ) ; cd $RHBASE/redhat ; umount /mnt
mount -o loop shrike-i386-disc3.iso /mnt ; cd /mnt ; tar -cf - * | ( cd $RHBASE/redhat/i386/ ; tar -xpf - ) ; cd $RHBASE/redhat ; umount /mnt

For each of the three source CDs do the following:

mount -o loop shrike-SRPMS-disc1.iso /mnt ; cd /mnt ; tar -cf - * | ( cd $RHBASE/redhat/i386/ ; tar -xpf - ) ; cd $RHBASE/redhat ; umount /mnt
mount -o loop shrike-SRPMS-disc2.iso /mnt ; cd /mnt ; tar -cf - * | ( cd $RHBASE/redhat/i386/ ; tar -xpf - ) ; cd $RHBASE/redhat ; umount /mnt
mount -o loop shrike-SRPMS-disc3.iso /mnt ; cd /mnt ; tar -cf - * | ( cd $RHBASE/redhat/i386/ ; tar -xpf - ) ; cd $RHBASE/redhat ; umount /mnt

If all went well, you can erase the installation ISO files. (You may need the space!)

Step 2: DAC960 Fix

The following steps are required only if you are attempting to fix a booting issue with the DAC960 RAID controller. (The installation CD released by Redhat has a bug which does not allow Redhat 9 to be installed on some computers.)

Proceed to Step 3 if you wish to skip this step.

First, retrieve the latest RedHat 9 kernel source update from a RedHat mirror site. (At the time of writing this web page, it was: kernel-2.4.20-18.9.src.rpm)

Install the RPM by typing:

rpm -i kernel-2.4.20-18.9.src.rpm

Go to the /usr/src/redhat/SOURCES directory and modify the following lines in the kernel-2.4.20-i386-BOOT.config file:

# CONFIG_X86_UP_APIC is not set
# CONFIG_X86_UP_IOAPIC is not set

Change them to:

CONFIG_X86_UP_APIC=y
CONFIG_X86_UP_IOAPIC=y

Go to the /usr/src/redhat directory and rebuild all of the kernel RPMs by typing:

rpmbuild -ba SPECS/kernel-2.4.spec

This will take a while, but if all goes well, there should be a new set of kernel RPMs in these directories:

/usr/src/redhat/RPMS/i386
/usr/src/redhat/RPMS/i686
/usr/src/redhat/RPMS/athlon

Replace the BOOT kernel in the $RHBASE/redhat/i386/RedHat/RPMS directory with the corresponding update from the /usr/src/redhat/RPMS/i386 directory. To do this, type the following command:

cp /usr/src/redhat/RPMS/i386/kernel-BOOT-2.4.20-18.9.i386.rpm $RHBASE/redhat/i386/RedHat/RPMS/.

Step 3: Other updates

If desired at this point, you can download any available updates from a Redhat mirror site and replace each RPM package in the $RHBASE/redhat/i386/RedHat/RPMS directory with its update.

Step 4: Cleanup

Many files will have been left around by the original CD creation process. These files will need to be removed with the following command:

find $RHBASE/redhat/i386 -name TRANS.TBL -exec rm -f {} \;

Step 5: Build

Here's the part we've been waiting for. If all has gone without a hitch, it's time to proceed to the build phase.

First, we need to re-generate the hdlist file. Do so with the following command:

genhdlist $RHBASE/redhat/i386

Next, create our package order file by issuing the following command:

pkgorder $RHBASE/redhat/i386 i386 | tee $RHBASE/redhat/pkgorder.txt

Now, update the installation files by entering the following command:

buildinstall --comp dist-9 --pkgorder $RHBASE/redhat/pkgorder.txt --version 9 --product "Red Hat Linux" --release "Custom build 1.0" $RHBASE/redhat/i386

Step 6: CD creation

Now that we have completed the build, it's time to split up the files into their CDs and make new ISOs. The following commands will do the split and re-create the hdlist files for each CD:

RELEASE="RedHat 9 (Shrike) with updates to $(date '+%Y-%M-%d %H:%m')"
splitdistro --fileorder $RHBASE/redhat/pkgorder.txt --release "$RELEASE" $RHBASE/redhat i386

rm -f $RHBASE/i386-disc1/RedHat/base/hdlist*
genhdlist --withnumbers --fileorder $RHBASE/redhat/pkgorder.txt $RHBASE/redhat/i386-disc[123]

Finally, create a bash script with the commands listed below and execute it. This will create brand new modified ISO images, which you can use to install Redhat Linux!

#!/bin/sh

myname='Joe Blow <joe@joe.blow>'
bootimg="isolinux/isolinux.bin"
bootcat="isolinux/boot.cat"
distname="shrike"
distvers="9"
mkisopts="-R -J -T"
bootopts="-no-emul-boot -boot-load-size 4 -boot-info-table"
mydate="$(date '+%d %b %Y')"
mkisofs $mkisopts $bootopts \
-V "RedHat $distver ($distname) UPDATED Disk 1" \
-A "RedHat $distver ($distname) update created on $mydate" \
-P "$myname" \
-p "$myname" \
-b "$bootimg" \
-c "$bootcat" \
-x lost+found \
-o "$distname"-i386-disc1.iso \
i386-disc1

for i in 2 3 ; do
mkisofs $mkisopts \
-V "RedHat $distver ($distname) UPDATED Disk $i" \
-A "RedHat $distver ($distname) update created on $mydate" \
-P "$myname" \
-p "$myname" \
-x lost+found \
-o "$distname"-i386-disc${i}.iso \
i386-disc${i}
done

for i in 1 2 3 ; do
mkisofs $mkisopts \
-V "RedHat $distver ($distname) UPDATED Disk $i" \
-A "RedHat $distver ($distname) update created on $mydate" \
-P "$myname" \
-p "$myname" \
-x lost+found \
-o "$distname"-SRPMS-disc${i}.iso \
i386-disc$(( $i + 3 ))
done