Re: modifying initrd.img

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's an example script we use to shove in customized drivers. You may
be able to pick out what's happening from it...

This is a kludge though. It avoids actually rebuilding through the
Anaconda source...

			- Matt

Daniel Shahin wrote:
> 
> does anyone know how to modify the initrd.img file.  I'd really like to
> pick this apart, and be able to customize the mini-distro, to add other
> tools, if possible.  Does anyone have any experience doing this?  Any
> pointers?
> 
> thanks in advance,
> 
> dshahin
> 
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/kickstart-list

-- 
---------------------------------------------------------------------
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/7.1"
BOOTIMAGE="$REDHATIMAGE/images/pcmcia.img"
DRIVERIMAGE="$REDHATIMAGE/images/pcmciadd.img"
ADDPCMCIAMODS="pcmcia_core.o i82365.o ds.o yenta_socket.o tcic.o \
               airo_cs.o airo.o aironet4500_core.o aironet4500_cs.o \
               aironet4500_proc.o"

# 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"

#
# 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
mkdir -p $NEWMODULES

# Mount the boot image and copy out and uncompress the
# "initrd.img" file
echo "Pulling out 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)

# Mount the driver disk and copy out the new modules to add.
echo "Mounting and unpacking new modules."
cp $DRIVERIMAGE $TMPAREA		# Need to copy off of NFS
mount -o loop -t ext2 "$TMPAREA/`basename $DRIVERIMAGE`" $MOUNT2
zcat < $MOUNT2/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.
releasedir=`cd $TMPAREA ; echo [0-9]*BOOT`
echo "Copying new modules and module settings for $releasedir."
for module in $ADDPCMCIAMODS
do
    # Copy in the module itself
    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 $MOUNT2/modinfo >> $MOUNT1/modules/module-info

    # Add any matching module dependancies
    grep "^$basemodule:" $MOUNT2/modules.dep >> $MOUNT1/modules/modules.dep

    # Add any matching "pcitable" entries
    grep "[ 	]\"$basemodule\"[ 	]" $MOUNT2/pcitable >> \
        $MOUNT1/modules/pcitable
done
# Done with this
umount $MOUNT2

# 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	0x4800	"airo"		"AIRONET Wireless Communications|PC4800"
.EOF1
#cat >> $MOUNT1/modules/pcitable << .EOF1
#0x14b9	0x0340	"aironet4500_card"	"AIRONET Wireless Communications|PC340"
#0x14b9	0x0350	"aironet4500_card"	"AIRONET Wireless Communications|PC350"
#0x14b9	0x4800	"aironet4500_card"	"AIRONET Wireless Communications|PC4800"
#.EOF1
cat >> $MOUNT1/modules/module-info << .EOF2
airo
	eth
	"AIRONET Wireless Communications PCXXXX"
aironet4500_card
	eth
	"AIRONET Wireless Communications PCXXXX"
.EOF2
cp $REDHATIMAGE/ourmodules/aironet4500_card.BOOT.o \
   $TMPAREA/$releasedir/aironet4500_card.o
cp $REDHATIMAGE/ourmodules/airo.BOOT.o \
   $TMPAREA/$releasedir/airo.o
echo "options airo ssids=$SSIDS" >> $MOUNT1/etc/modules.conf

# 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

[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux