Bug 141845 - mkinitrd does not support compressed modules for 2.6 kernel
Summary: mkinitrd does not support compressed modules for 2.6 kernel
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: mkinitrd
Version: 4.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Brian Lane
QA Contact:
URL:
Whiteboard: FC4 RHEL4U1
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-12-04 00:04 UTC by David Ahern
Modified: 2011-07-27 17:57 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-27 17:57:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description David Ahern 2004-12-04 00:04:11 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET
CLR 1.1.4322)

Description of problem:
The following patch adds support to mkinitrd for compressed modules
with the 2.6 kernel. Any chance this can be added to the standard rpm?

--- mkinitrd.orig	2004-11-18 14:58:36.000000000 -0700
+++ mkinitrd	2004-11-18 16:36:14.000000000 -0700
@@ -71,7 +71,7 @@
 
     [ -n "$verbose" ] && echo -n "Looking for deps of module $1"
     deps=$(awk 'BEGIN { searched=ARGV[2]; ARGV[2]=""; rc=1 } \
-                function modname(filename) { match(filename,
/\/([^\/]+)\.k?o:?$/, ret); return ret[1] } \
+                function modname(filename) { match(filename,
/\/([^\/]+)\.k?o(.gz):?$/, ret); return ret[1] } \
                 function show() { if (orig == searched) { print dep;
orig=""; rc=0; exit } } \
                 /^\/lib/ { show(); \
                            orig=modname($1); dep=""; \
@@ -121,12 +121,13 @@
 	modName="sbp2"
     else
 	moduledep $modName
+    	[ -n "$verbose" ] && echo "deps for $modName: $deps"
 	for i in $deps; do
 	    findmodule $i
 	done
     fi
 
-    for modExt in o.gz o ko ; do
+    for modExt in o.gz o ko ko.gz ; do
 	if [ -d /lib/modules/$kernel/updates ]; then
 	    fmPath=`(cd /lib/modules/$kernel/updates; echo find . -name
$modName.$modExt -type f | /sbin/nash --quiet) | /bin/awk {'print $1;
exit;'}`
 	fi
@@ -589,7 +590,21 @@
 
 for MODULE in $MODULES; do
     if [ -x /usr/bin/strip ]; then
+	case $MODULE in
+		*.gz)
+			m=${MODULE##*/}
+			cp /lib/modules/$kernel/$MODULE  /tmp
+			gunzip /tmp/$m
+			m=${m%.gz}
+			/usr/bin/strip -g $verbose /tmp/$m -o $MNTIMAGE/lib/$m
+			#gzip $MNTIMAGE/lib/$m
+			rm -f /tmp/$m
+			;;
+
+		*)
 	/usr/bin/strip -g $verbose /lib/modules/$kernel/$MODULE -o
$MNTIMAGE/lib/$(basename $MODULE)
+		;;
+	esac
     else
 	cp $verbose -a /lib/modules/$kernel/$MODULE $MNTIMAGE/lib
     fi
@@ -658,6 +673,7 @@
 fi
 
 for MODULE in $MODULES; do
+    MODULE=${MODULE%.gz}
     text=""
     module=`echo $MODULE | sed "s|.*/||" | sed "s/.k\?o$//"`
     fullmodule=`echo $MODULE | sed "s|.*/||"`

Version-Release number of selected component (if applicable):
mkinitrd-4.1.18-2

How reproducible:
Always

Steps to Reproduce:
1. compress modules in /lib/modules/<kernel ver>/...
2. build dependency file for it
3. attempt to run mkinitrd
    

Additional info:

Comment 1 Jeremy Katz 2004-12-06 16:19:00 UTC
The module loading infrastructure in 2.6 doesn't natively support
compressed modules, so adding them involves adding a lot of calls to
gunzip before you could ever load a module which is cumbersome at best.

Better question...  Why are you wanting to compress the modules?

Comment 2 David Ahern 2004-12-06 16:26:28 UTC
The module-init-tools rpm has zlib support enabled, so insmod and
modprobe both support compressed modules. This mkinitrd change was the
only change needed to get a system working with compressed modules.

One of our new products will have very limited disk space. Using
compressed modules saves ~50M of disk space and it allows us to have a
single kernel rpm for all of our server types.

Comment 3 Jeremy Katz 2004-12-06 16:30:59 UTC
Unfortunately, at this point, it's too late to get enhancements into
RHEL4.  That doesn't seem unreasonable (although, the patch is a
little bit ugly), so will leave on the table for an update or similar.

Comment 4 David Ahern 2004-12-06 16:45:21 UTC
What about the patch do you consider ugly? If it is a matter of
cleanup, I can re-do the patch.


Comment 5 Suzanne Hillman 2004-12-06 20:18:40 UTC
Internal RFE bug #142028 entered; will be considered for future releases.

Comment 6 David Ahern 2004-12-18 00:41:36 UTC
A '?' was missing from one of the lines. The following is an updated
patch that has been tested with compressed and uncompressed modules:


--- mkinitrd.orig	2004-11-18 14:58:36.000000000 -0700
+++ mkinitrd	2004-11-18 16:36:14.000000000 -0700
@@ -71,7 +71,7 @@
 
     [ -n "$verbose" ] && echo -n "Looking for deps of module $1"
     deps=$(awk 'BEGIN { searched=ARGV[2]; ARGV[2]=""; rc=1 } \
-                function modname(filename) { match(filename,
/\/([^\/]+)\.k?o:?$/, ret); return ret[1] } \
+                function modname(filename) { match(filename,
/\/([^\/]+)\.k?o(.gz)?:?$/, ret); return ret[1] } \
                 function show() { if (orig == searched) { print dep;
orig=""; rc=0; exit } } \
                 /^\/lib/ { show(); \
                            orig=modname($1); dep=""; \
@@ -121,12 +121,13 @@
 	modName="sbp2"
     else
 	moduledep $modName
+    	[ -n "$verbose" ] && echo "deps for $modName: $deps"
 	for i in $deps; do
 	    findmodule $i
 	done
     fi
 
-    for modExt in o.gz o ko ; do
+    for modExt in o.gz o ko ko.gz ; do
 	if [ -d /lib/modules/$kernel/updates ]; then
 	    fmPath=`(cd /lib/modules/$kernel/updates; echo find . -name
$modName.$modExt -type f | /sbin/nash --quiet) | /bin/awk {'print $1;
exit;'}`
 	fi
@@ -589,7 +590,21 @@
 
 for MODULE in $MODULES; do
     if [ -x /usr/bin/strip ]; then
+	case $MODULE in
+		*.gz)
+			m=${MODULE##*/}
+			cp /lib/modules/$kernel/$MODULE  /tmp
+			gunzip /tmp/$m
+			m=${m%.gz}
+			/usr/bin/strip -g $verbose /tmp/$m -o $MNTIMAGE/lib/$m
+			#gzip $MNTIMAGE/lib/$m
+			rm -f /tmp/$m
+			;;
+
+		*)
 	/usr/bin/strip -g $verbose /lib/modules/$kernel/$MODULE -o
$MNTIMAGE/lib/$(basename $MODULE)
+		;;
+	esac
     else
 	cp $verbose -a /lib/modules/$kernel/$MODULE $MNTIMAGE/lib
     fi
@@ -658,6 +673,7 @@
 fi
 
 for MODULE in $MODULES; do
+    MODULE=${MODULE%.gz}
     text=""
     module=`echo $MODULE | sed "s|.*/||" | sed "s/.k\?o$//"`
     fullmodule=`echo $MODULE | sed "s|.*/||"`


Note You need to log in before you can comment on or make changes to this bug.