Re-creating CentOS 5.x media with a custom kernel

This page explains how to recreate your i386 CentOS 5.x media, which uses a custom kernel on installation.

Installer of the official CentOS 5.x media uses i686 kernel, so it

In these cases, you would like to spin your own install media with kernel replaced.

Keywords: CentOS 5.x, RHEL 5.x, Linux kernel, i586, installation media, install CD, install DVD, anaconda, AMD K6-2

$Id: dvd.m4,v 1.17 2016/07/25 07:41:44 kabe Exp $ (2011/07)


Things you need


Step 1. Install anaconda-runtime

Install anaconda-runtime RPM package included in the official repository or media with your favorite installation method.

	% sudo yum --disablerepo='*' --enablerepo=c5-media install anaconda-runtime

Don't skip the dependent packages; you need them all.

/usr/lib/anaconda-runtime/ will be populated.


Step 2. Copy over the original media

Mount the original CentOS 5.x media. Copy over, or make a symlink farm, as ./mymedia . Clean up the TRANS.TBL files as necessary. If the disk free space is short, a symlink farm is sufficient as below.

	% rm -fr ./mymedia
	% cp -r --symbolik-link /media/dvd ./mymedia
	% find ./mymedia -name TRANS.TBL -exec rm {} ';'

Then, copy your custom kernel into ./mymedia/CentOS/ directory which holds other *.rpm .

	% ln -s `pwd`/kernel-2.6.18-238.12.1.el5.v8.i586.rpm ./mymedia/CentOS
	% ln -s `pwd`/kernel-devel-2.6.18-238.12.1.el5.v8.i586.rpm ./mymedia/CentOS


Step 3. buildinstall

/usr/lib/anaconda-runtime/buildinstall is a program to prepare the installer (anaconda) things you see in the media.

First, check out the .treeinfo at the root of the media. It will be something like

	[general]
	family = CentOS
	timestamp = 1301440499.8
	totaldiscs = 1
	version = 5.6
	discnum = 1
	packagedir = CentOS
	arch = i386
Take note of family, version and packagedir .

Delete things recreated by buildinstall beforehand.

	% rm -f ./mymedia/.discinfo
	% rm -f ./mymedia/.treeinfo
	% rm -fr ./mymedia/images
	% rm -fr ./mymedia/isolinux
	% rm -f ./mymedia/repodata/*
You would need content of repodata/comps.xml, so re-copy or move it out on other place before deleting. I will assume /media/dvd/repodata/comps.xml is still intact.

Then, invoke the buildinstall with some options.

	% sudo /usr/lib/anaconda-runtime/buildinstall --debug \
	   --product CentOS --version 5.6 --prodpath CentOS \
	   --release Final-i586 \
	   --pkgorder ./mymedia/repodata/pkgorder --comps /media/dvd/repodata/comps.xml \
	   ./mymedia
This takes a long time! About 1 hour on PentiumIII 400MHz, 9 hours on 300MHz i586 machine. You would like to redirect the output to a logfile.

Unexpected sudo is needed to let buildinstall use a loopback filesystem.

Internally called createrepo will consume ~300MB of memory. Expect heavy thrashing if the work machine has less.

/tmp/ should have about a gigabyte of free space; in CentOS 5 buildinstall, location of /tmp/ is not configurable.

As a result, the files you deleted above will be recreated. Scratch directories may be lying around in /tmp/, so check out and delete them afterwards.

The recreated files are likely owned by root, so you would like to

	% sudo chown -R $LOGNAME ./mymedia

The generated ./mymedia/images/boot.iso of about 8MB should boot as a network installer. Try if you're impatient, or want to be sure you didn't goof.

Discussion

buildinstall does not use the native files of the host machine to build the installer; it unpacks files from the *.rpm in the directory. Thus the host doesn't have to be i386; working on x86_64 should be okay.

Fortunately, buildinstall will pick up the i586 kernel and use it to build the installer if the kernel.i586.rpm file is in the package directory (--prodpath). So the above trick of dropping in the i586 kernel works (at least for CentOS 5 anaconda-runtime).

The generated images/boot.iso should now boot, but it won't recognize the official CentOS media as installation source. Selecting "Local CDROM" will emit following error:

No CentOS CD was found which matches your boot media. Please insert the CentOS CD and press OK to retry.
Reason: the embedded "/.buildstamp" in the generated boot.iso does not match with media's .buildstamp in ${MEDIA}/images/stage2.img .

So you need to re-spin the whole install media as following.


Step 4. mkisofs

Respin the media image by mkisofs.

First, isolinux.bin should be writeable to make it bootable, so

	% chmod -R +w ./mymedia/isolinux

Then, build the *.iso image:

	% mkisofs -v -o ./CentOS-5.6-i586-binDVD.iso \
	  -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
	  -r -J -V CENTOS_56_I586 -T -f ./mymedia

Then, embed the MD5 sum of the media you will use for mediacheck:

	% /usr/lib/anaconda-runtime/implantisomd5 --force ./CentOS-5.6-i586-binDVD.iso

A simple manpage of implantisomd5

Burn the *.iso and try it out on your favorite i586 machine. The resulting ISO image uses kernel.i586 and glibc.i386, so the installation should run on K6-2.


Troubleshooting


Alternatives:


References


kabe.sra-tohoku.co.jp