This is actually what we're doing. I build a custom "modules.cgz"
using a script we wrote to do basically what you're doing below. The
problem is that the resulting "initrd.img" when added to the kernel on
the floppy is too large. Subsiquently we need to (would like to)
shrink the kernel, but when I do, it doesn't seem to find the modules
(it appears not to be looking at the "/modules/modules.cgz").
Taking the same "modules.cgz" (minus some modules we can live without
for the particular test) with the default BOOT kernel, everything
seems to be found fine (well, at least the "e1000.o" we're looking for
- it's found under the path "/modules/modules.cgz").
I'm attaching our script we use if anyone is interested.
Thanks for all the responses.
- Matt
Jason Kohles wrote:
On Fri, Mar 28, 2003 at 02:12:07PM -0500, Matt Fahrner wrote:
Yeah, that was one of the possibilities, but one I was hoping to
avoid. Worst case that's how we'll go.
I was kind of hoping someone from RedHat was listening and might be
able to suggest what they do to customize the kernel to deal with
using "/modules/modules.cgz" in the search path...
The way I do it is to take the drivers and information I need from the
drvnet image, and add it to the bootnet image (actually I usually just
combine the two images entirely, and use a bootable cd rather than a
floppy). I don't see anything here that indicates if you are rebuilding
the modules.cgz or just new kernels with the drivers you need built in,
but when building a custom modules.cgz, the two things that you really
need to remember are
1. If you add a driver to modules.cgz, you also need to add the info for
it to module-info, pcitable, and possibly modules.dep
2. When rebuilding the modules.cgz, you have to specify the -H crc option
to cpio, or the modules.cgz won't be usable.
Here is a quick overview of how to copy a module from the drvnet modules.cgz
to the bootnet modules.cgz, which will hopefully get you started.
1. First, uncompress the bootnet and mount it on loopback
# zcat bootnet.img > unbootnet.img
# mkdir bootnet
# mount -o loop unbootnet.img bootnet
2. Then uncompress the bootnet initrd, and mount that on loopback
# zcat bootnet/initrd.img > initrd.img
# mkdir initrd
# mount -o loop initrd.img initrd
3. Then loopback mount the drvnet image (it isn't compressed)
# mkdir drvnet
# mount -o loop drvnet.img drvnet
4. Make an uncompressed copy of the modules.cgz for both disks
# zcat drvnet/modules.cgz > modules.cpio
# cpio -i --make-directories < modules.cpio
# mv 2.4.9-e.3BOOT modules-drvnet
(substitute the correct directory name for your bootdisk)
# zcat initrd/modules/modules.cgz > modules.cpio
# cpio -i --make-directories < modules.cpio
5. Now copy whatever modules you need from modules-drvnet to 2.4.9-e3BOOT
(or whatever the version is for the boot disk you are using, this is
the version from the AS 2.1 boot disk).
# cp modules-drvnet/e1000.o 2.4.9-e.3BOOT
# cp modules-drvnet/tg3.o 2.4.9-e.3BOOT
6. If you are going to put this on a floppy, you will probably have to
remove some other drivers from your module directory to make room, I
find the USB ones are generally a good target:
# rm 2.4.9-e.3BOOT/usb*
7. Now you need to look in the drvnet/modinfo file, and copy any entries
that are related to the modules you copied to your new modules directory
into the initrd/modules/module-info file. You can also remove entries
for any modules you deleted (you don't have to, but it might save you a
little space).
8. Now do the same thing for modules.dep and pcitable, copy any relevant
entries from the drvnet files to the initrd/modules files (these two
have the same name on both disks, I don't know why modinfo/module-info
is different).
9. Now you need to repackage and recompress your modules
# find 2.4.9-e.3BOOT > filelist
# cpio -o -H crc < filelist > modules.cpio
# gzip --best modules.cpio
# mv modules.cpio.gz initrd/modules/modules.cgz
(If this last step fails, try removing some other unneeded modules from
the module directory and repeat. Also make sure you don't have any of
the files from step 7 or 8 open in an editor, the swap file that vi or
emacs makes when you have a file open can suck up any extra space on the
disk).
10.Now unmount and recompress the initrd
# umount initrd
# gzip --best initrd.img
# mv initrd.img.gz bootnet/initrd.img
(If this fails, you probably need to remove more modules, although first
you can try getting rid of the *.msg files in bootnet/, they contain
information for the person doing the install, you generally never even
get the chance to seem them while kickstarting)
11.Unmount bootnet and put bootnet.img on a floppy to test.
Incidentally, the generic boot kernel has a lot of stuff enabled that
is a total waste (like "parallel port" support, which is hardly useful
at kickstart time).
parallel port support is more than useful if you want to do network installs
on machines without network support, PLIP is much faster than SLIP.
--
---------------------------------------------------------------------
Matt Fahrner 2 South Park St.
Manager of Networking Willis House
Burlington Coat Factory Warehouse Lebanon, N.H. 03766
TEL: (603) 448-4100 xt 5150 USA
FAX: (603) 443-6190 Matt.Fahrner@xxxxxxxx
---------------------------------------------------------------------
#! /bin/sh
#
# BCFBuildPCMCIAinitrd: build a BCF specific PCMCIA "initrd" file.
#
# It ain't pretty and it doesn't do any checks, but it's something.
PATH=/usr/bin:/bin:/usr/sbin:/sbin
export PATH
# Change these to reflect your requirements
REDHATIMAGE="/auto/redhat/8.1-new"
BOOTIMAGE="$REDHATIMAGE/images/bootdisk.img"
# Modules from the "pcmciadd.img"...
#ADDPCMCIAMODS="pcmcia_core.o i82365.o ds.o yenta_socket.o tcic.o"
ADDPCMCIAMODS="pcmcia_core.o i82365.o"
# Modules from the "drvnet.img"...
ADDNETMODS="3c59x.o e1000.o"
# Delete USB and SCSI modules
DELETEMODS="scsi_mod.o sd_mod.o usb-storage.o"
# BCF specific add on modules
BCFMODULES="$REDHATIMAGE/bcfbootmodules"
# BCF airo module SSIDS to add, comma separated
SSIDS="foobar"
# Where to unpack (don't change)
TMPAREA="/tmp/buildinitrd.$$"
MOUNT1="$TMPAREA/mount1"
MOUNT2="$TMPAREA/mount2"
NEWMODULES="$TMPAREA/newmodules"
#
# copymodulesfrom(): copy modules from an image.
#
# copymodulesfrom imagefile module1 ... modulen
#
copymodulesfrom()
{
imagefile="$1"
shift
# Mount the driver disk and copy out the new modules to add.
echo "Mounting and unpacking new modules from \"$imagefile\"."
cp $REDHATIMAGE/images/$imagefile $TMPAREA
# Use the right file type
case `file $TMPAREA/$imagefile` in
*FAT*) type="vfat" ;;
*) type="ext2" ;;
esac
mount -o loop -t $type $TMPAREA/$imagefile $MOUNT2
# Ok, check if this needs to be a two step process
MDIR=$MOUNT2
if [ -r $MOUNT2/initrd.img -a ! -r $MOUNT2/modules.cgz ]; then
echo "Is two level image. Pulling initrd.img."
# Ok, this is actually burried in an initrd image
zcat $MOUNT2/initrd.img > $TMPAREA/image-initrd
umount $MOUNT2
mount -t ext2 -o loop $TMPAREA/image-initrd $MOUNT2
MDIR=$MOUNT2/modules
fi
# Find paths
MODINFO=$MDIR/modinfo
if [ -r $MDIR/module-info ]; then
MODINFO=$MDIR/module-info
fi
# Clean up and extract modules
rm -rf $NEWMODULES # Cleanup old
mkdir -p $NEWMODULES # Rebuild
zcat < $MDIR/modules.cgz | (cd $NEWMODULES ; cpio --quiet -id)
# Now copy the new modules from the driver disk to our build module
# area making sure to get all the dependancies.
echo -n "Copying new modules and settings... "
for module in $@
do
# Copy in the module itself
echo -n "$module "
cp $NEWMODULES/$releasedir/$module $TMPAREA/$releasedir
# Add any matching module info
basemodule=`echo $module | sed 's/\..*//'`
awk '{
if ($0 !~ /^[ ]/) {
if ($1 == basemodule) {
start = 1
print $0
} else
start = 0
} else {
if (start)
print $0
}
}' basemodule=$basemodule $MODINFO >> $MOUNT1/modules/module-info
# Add any matching module dependancies
grep "^$basemodule:" $MDIR/modules.dep >> $MOUNT1/modules/modules.dep
# Add any matching "pcitable" entries
grep "[ ]\"$basemodule\"[ ]" $MDIR/pcitable >> \
$MOUNT1/modules/pcitable
done
# Done with this
umount $MOUNT2
echo "(done)"
return 0
}
#
# Main: main code.
#
# Build a place to put the stuff
echo "Starting initrd.img build under $MOUNT1..."
rm -rf $TMPAREA
mkdir -p $MOUNT1
mkdir -p $MOUNT2
# Mount the starting boot image and copy out and uncompress the
# "initrd.img" file
echo "Pulling out PCMCIA initrd image."
cp $BOOTIMAGE $TMPAREA # Need to copy off of NFS
mount -o loop -t vfat "$TMPAREA/`basename $BOOTIMAGE`" $MOUNT1
zcat < $MOUNT1/initrd.img > $TMPAREA/initrd
umount $MOUNT1
rm -f "$TMPAREA/`basename $BOOTIMAGE`"
# Mount the uncompressed "initrd" image to manipulate and unpack the
# generic set of modules. This should create a "2.4.2-2BOOT"
# directory with the modules.
echo "Pulling generic modules out of initrd."
mount -o loop -t ext2 $TMPAREA/initrd $MOUNT1
zcat < $MOUNT1/modules/modules.cgz | (cd $TMPAREA ; cpio --quiet -id)
# Establish the release information this area
releasedir=`cd $TMPAREA ; echo [0-9]*BOOT`
echo "Release is: $releasedir"
# Copy in the added modules
copymodulesfrom pcmciadd.img $ADDPCMCIAMODS
copymodulesfrom drvnet.img $ADDNETMODS
if [ 1 = 0 ]; then
# Copy in BCF modules (overrides)
if [ -d $BCFMODULES ]; then
echo -n "Adding custom compiled BCF modules... "
(cd $BCFMODULES
for module in *
do
echo -n "$module "
cp $module $TMPAREA/$releasedir
done
echo "(done)")
fi
#
# Add our specific changes
#
echo "Adding BCF specific changes."
cat >> $MOUNT1/modules/pcitable << .EOF1
0x14b9 0x0340 "airo" "AIRONET Wireless Communications|PC340"
0x14b9 0x0350 "airo" "AIRONET Wireless Communications|PC350"
0x14b9 0x0001 "airo" "AIRONET Wireless Communications|PC4800"
0x14b9 0x0340 "airo" "AIRONET Wireless Communications|PC4800"
0x14b9 0x0350 "airo" "AIRONET Wireless Communications|PC4800"
0x14b9 0x4500 "airo" "AIRONET Wireless Communications|PC4500"
0x14b9 0x4800 "airo" "AIRONET Wireless Communications|PC4800"
.EOF1
# By default aironet isn't known as ethernet device for boot
cat >> $MOUNT1/modules/module-info << .EOF2
airo
eth
"AIRONET Wireless Communications PCXXXX"
.EOF2
# Fix PCMCIA config for "airo"
awk '{
if (NF == 4 && $1 == "class" && $2 == "\"network\"" && $3 == "module" &&
$4 == "\"airo_cs\"")
{
printf(" %s %s %s \"airo\", %s\n", $1, $2, $3, $4)
} else
print $0
}' $MOUNT1/etc/pcmcia/config > $MOUNT1/etc/pcmcia/config.$$
mv $MOUNT1/etc/pcmcia/config.$$ $MOUNT1/etc/pcmcia/config
# Add aironet SSID options (doesn't seem to work)
echo "options airo ssids=$SSIDS" >> $MOUNT1/etc/modules.conf
fi
# Ok, now delete any modules in our delete list. Note we
# ought to clean up "module-info" et al but...
echo "Cleaning modules marked to delete."
for name in $DELETEMODS
do
rm -f $TMPAREA/$releasedir/$name
done
# Now take the now modules area and repack it
echo "Packing new modules."
(cd $TMPAREA ; find $releasedir -print | cpio --quiet -H crc -o |
gzip -9 > $MOUNT1/modules/modules.cgz)
# Unmount the "initrd" image and repack it
echo "Writing new initrd.img to \"./initrd.img\"."
umount $MOUNT1
gzip -9 < $TMPAREA/initrd > initrd.img
# Cleanup
rm -rf $TMPAREA
echo "Done!"
exit 0