Bug 141845 - mkinitrd does not support compressed modules for 2.6 kernel
mkinitrd does not support compressed modules for 2.6 kernel
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: mkinitrd (Show other bugs)
4.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Brian Lane
FC4 RHEL4U1
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-03 19:04 EST by David Ahern
Modified: 2011-07-27 13:57 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-07-27 13:57:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description David Ahern 2004-12-03 19:04:11 EST
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 11:19:00 EST
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 11:26:28 EST
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 11:30:59 EST
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 11:45:21 EST
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 15:18:40 EST
Internal RFE bug #142028 entered; will be considered for future releases.
Comment 6 David Ahern 2004-12-17 19:41:36 EST
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.