rebuild official kernel with only the modules you need / mapping module names back to CONFIG options
Hi,
while struggling with various kernel bugs[1] this year I had to do a
lot of rebuilds to test patches. I wanted proper source packages that
I can share from my private debian repository and also wanted
-headers, -dbg and -source binary packages. Most importantly I wanted
proper changelog entries. I could not figure out how to do this with
make-kpkg so I thought I'd dig into the real thing, linux-2.6.
http://wiki.debian.org/HowToRebuildAnOfficialDebianKernelPackage has a
fairly good guide on how to rebuild kernels. However, it requires one
to either recompile all flavors or to live without -headers [2]. I
don't really understand the build system fully but with a patch[3]
simply running "debuild --no-lintian -e DEB_BUILD_OPTIONS="parallel=4"
created only
which is everything I need but without too much extra. Should I put
this to the wiki and replace the old "make -f debian/rules.gen
binary-arch_i386_none_686 binary-indep" tricks?
Next problem: The unpacked -dbg package takes almost 1.5 GB of disk
space. The thought of having to run make menuconfig to manually
disable modules that I don't need was scary so I automated the
process. This is somewhat hacky but I thought it might be useful to
someone:
1) http://iki.fi/lindi/linux/find-config-option-for-module-file takes
a path to a kernel module as an argument and prints the CONFIG option
that enables it. It needs to be run directory that contains unpacked
/usr/src/linux-source-2.6.32.tar.bz2:
3) cat module-to-config.map | while read file option; do module=$(basename $file|sed 's/.ko$//;s/-/_/g'); if [ "$(lsmod|awk '{print $1}'|grep "^$module$")" = "" ]; then echo $option; fi; done > unnecessary-options.lst
lists all CONFIG options that are not associated with a module that is
currently loaded according to lsmod.
4) for i in $(cat unnecessary-options.lst); do sed -i "s/$i=m/# $i is not set/" $(find debian/config -type f); done
edits all the debian/config/** files so that all unnecessary options
are disabled.
=> With all this in place I get nice "almost like official" kernels
that have everything I need but take almost no time to build and
almost no time to copy over network:
38M Nov 9 12:55 linux-image-2.6.32-5+lindi.5-amd64-dbg_2.6.32-27+lindi.5_amd64.deb
3.8M Nov 9 12:55 linux-headers-2.6.32-5+lindi.5-common_2.6.32-27+lindi.5_amd64.deb
3.4M Nov 9 12:55 linux-image-2.6.32-5+lindi.5-amd64_2.6.32-27+lindi.5_amd64.deb
816K Nov 9 12:56 linux-libc-dev_2.6.32-27+lindi.5_amd64.deb
289K Nov 9 12:55 linux-headers-2.6.32-5+lindi.5-amd64_2.6.32-27+lindi.5_amd64.deb
287K Nov 9 12:56 linux-tools-2.6.32_2.6.32-27+lindi.5_amd64.deb
202K Nov 9 12:56 linux-2.6_2.6.32-27+lindi.5_amd64.build
158K Nov 9 12:55 linux-base_2.6.32-27+lindi.5_all.deb
150K Nov 9 12:55 linux-support-2.6.32-5+lindi.5_2.6.32-27+lindi.5_all.deb
134K Nov 9 12:56 linux-headers-2.6.32-5+lindi.5-all-amd64_2.6.32-27+lindi.5_amd64.deb
134K Nov 9 12:56 linux-headers-2.6.32-5+lindi.5-all_2.6.32-27+lindi.5_amd64.deb
17K Nov 9 12:56 linux-2.6_2.6.32-27+lindi.5_amd64.changes
[2] "Problem: In this case, linux-headers-2.6.24-1+foo.1-common will
be missing. One needs to invoke the binary-arch_i386 target, which
will yield all feature sets (Xen, VServer) and flavours to be
generated, and obviously takes a lot longer. See
http://lists.debian.org/debian-kernel/2008/04/msg00190.html"
--
To UNSUBSCRIBE, email to debian-kernel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 84fwvaismh.fsf@sauna.l.org">http://lists.debian.org/84fwvaismh.fsf@sauna.l.org