Quick build of stripped-down kernel

b. f. bf1783 at googlemail.com
Thu Nov 24 15:17:13 UTC 2011

> Happy Thanksgiving! This week, I've been building FreeBSD 9.0-RC2

And to you, too.

> kernels for various machines, and on some of the older and slower
> ones it's been taking quite a long time. One of the reasons for
> this is that even if you strip 98% of the drivers out of the
> kernel, they are all still built as loadable modules. The machines
> in question will NEVER use those modules, so it's a waste of time
> and disk space.
> How hard would it be to create a build target for "make" that would
> avoid building the loadable modules and just leave them out of the
> directory where the new kernel is placed after installation? I am
> not intimately familiar with the cascade of makefiles that does the
> build.... I could probably figure out what to tweak, but if someone
> who is expert in this can help it would be appreciated. It would
> save me countless hours.

If you are going to build most of the modules, but only want to
exclude a few, then add the directories of the modules to be excluded
(relative to /usr/src/sys/modules) to WITHOUT_MODULES, for example in
/etc/make.conf. If you are only going to build a few modules, and want
to exclude the majority of the modules, then add the directories of
the modules that are to be built to MODULES_OVERRIDE.  For no modules
at all, set NO_MODULES.  See /usr/src/sys/modules/Makefile and
/usr/src/sys/conf/kern.post.mk for details. You may also save some
time by using one of your faster machines to build the OS for the
slower machines.


More information about the freebsd-questions mailing list