Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 52558 - initrd's *need* ext2 support in the kernel, lets make sure it's there
Summary: initrd's *need* ext2 support in the kernel, lets make sure it's there
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: x86 Linux
: High enhancement (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2004-05-31 08:08 UTC by Mike Williams
Modified: 2004-09-15 04:28 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Williams 2004-05-31 08:08:13 UTC
In a small moment of forgetfulness I forgot to compile ext2 support into my kernel when switching from manual compilation to using genkernel.
I don't use ext2, so only had it as a module.
Naturally that kernel was broken, as it couldn't mount the ext2 initrd.

No doubt more people will do similar, and have done in the past.
So if people want to use the initrd, ext2 is very much a required feature, lets turn it on if off.

sauron genkernel # diff -u gen_configkernel.sh.orig gen_configkernel.sh
--- gen_configkernel.sh.orig    2004-05-31 15:12:16.572117703 +0100
+++ gen_configkernel.sh 2004-05-31 15:28:33.380547637 +0100
@@ -82,4 +82,10 @@
                [ "$?" != "0" ] && gen_die "Error: xconfig failed."
        fi

+       EXT2CFG=`egrep "CONFIG_EXT2_FS=m|CONFIG_EXT2_FS is not set" .config`
+       if [ "${EXT2CFG}" != "" ]
+       then
+               sed -i .config -e "s/${EXT2CFG}/CONFIG_EXT2_FS=y/"
+       fi
+
 }

Perhaps a configuration option could be added to optionally skip this.

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Tim Yamin (RETIRED) gentoo-dev 2004-05-31 08:45:01 UTC
There's no need to use ``egrep'' there since you can just do a grep for "CONFIG_EXT2_FS=y" and if it's not there; and then you can do an "s/CONFIG_EXT2_FS=.+/CONFIG_EXT2_FS=y/"... If you could tweak that patch and attach a new one I'd be happy to add it into the next release.

Thanks!
Comment 2 Mike Williams 2004-05-31 08:53:07 UTC
Thanks for the quick feedback!

I used an egrep to count for the possibility of ext2 support being turned off alltogether.
Your example wouldn't work there, as the sed wouldn't find 'CONFIG_EXT2_FS=.+'.
Plus in my 2.6.5 kernel config there are 2 lines matching 'CONFIG_EXT2_FS', hence the belt and braces approach.
Comment 3 Tim Yamin (RETIRED) gentoo-dev 2004-05-31 09:12:39 UTC
Good point, but it can still be done with a simple sed:

$ cat tempConfig
CONFIG_EXT2_FS=m
CONFIG_EXT2_FS=y
# CONFIG_EXT2_FS is not set

CONFIG_EXT2_FS_MOO=m
CONFIG_EXT2_FS_MOO=y
# CONFIG_EXT2_FS_MOO is not set

$ grep 'CONFIG_EXT2_FS=y' tempConfig
CONFIG_EXT2_FS=y

$ sed tempConfig -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g'
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS=y

CONFIG_EXT2_FS_MOO=m
CONFIG_EXT2_FS_MOO=y
# CONFIG_EXT2_FS_MOO is not set
Comment 4 Mike Williams 2004-05-31 09:25:14 UTC
Oh, sed god :)
I see what it's doing, but don't really understand how the '#\? \?' bit work.

Anyway, updated patch.

--- gen_configkernel.sh.orig    2004-05-31 15:12:16.000000000 +0100
+++ gen_configkernel.sh 2004-05-31 17:24:08.649960120 +0100
@@ -82,4 +82,7 @@
                [ "$?" != "0" ] && gen_die "Error: xconfig failed."
        fi

+       # Make sure EXT2 support is turned on.
+       sed -i .config -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g'
+
 }
Comment 5 Tim Yamin (RETIRED) gentoo-dev 2004-05-31 09:37:32 UTC
\? = a GNU sed extension for "match previous character once, or no times".

Therefore, "#\? \?Moo" will match "Moo", " Moo", "#Moo" and "# Moo" which suits us fine just incase the .config is not in the best shape somehow.

One could also do 's/^\(# \)\?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' which will only match 'CONFIG_'... and '# CONFIG...' but that incurs the penalty of having to store '# ' in a buffer and then not even use it...
Comment 6 Tim Yamin (RETIRED) gentoo-dev 2004-07-28 03:59:29 UTC
The patch should be in Portage with genkernel-3.0.2e; please reopen this bug if you have any issues with it. Thanks!
Comment 7 Joël 2004-09-15 04:28:20 UTC
I use a cramfs initrd; so ext2 is not needed for me.

Is it possible to add a command-line switch, to prevent forcing ext2 for those who don't want it ?

Or (the better solution?) -- give the choice between a ext2 or cramfs initrd ? I think displaying a warning if the user forgets ext2 is fine, but forcing ext2 for everyone without notice is not too good (imho).

Btw I have a script which turns genkernel's ext2 initrd into a cramfs. I'll sure provide it if someone is interested !