prevent kernel building a built in module

Pegasus711

Member

Reaction score: 4
Messages: 64

Hello friends

I'm trying to experiment a bit with NIC drivers on my VM and would like the kernel to not auto load if_em.ko but it just won't stop loading it. Is there a way to do that? In my custom kernel config file, I have commented out
device em
but when I check after building /boot/kernel, if_em still seems to get built. Am I missing something? I have also update /etc/make.conf with
WITHOUT_MODULES=if_em
but to no avail.

Awaiting your suggestions
 
OP
P

Pegasus711

Member

Reaction score: 4
Messages: 64

Well, I've used WITHOUT_MODULES but it doesn't seem to work as intended. And there have been threads on mailing lists saying the same (I wonder if they've made it work now). Is there something else one can try?
 

Speedy

Well-Known Member

Reaction score: 25
Messages: 301

I've used MODULES_OVERRIDE myself for long time and it always worked for me. Never tried WITHOUT_MODULES, though.
 
OP
P

Pegasus711

Member

Reaction score: 4
Messages: 64

With MODULES_OVERRIDE I need to make sure all modules that are *actually* needed to run my HW are present. I really wished WITHOUT_MODULES would work
 

Speedy

Well-Known Member

Reaction score: 25
Messages: 301

Don't know, I have everything I need built into kernel and I have only two modules (which I load only when I need them).
 
OP
P

Pegasus711

Member

Reaction score: 4
Messages: 64

Well good for you but in my own case, I need to watch some stuff at driver load so this is not an option. I wished there was an option similar to the 'M' option in the Linux kernel alas it looks there isn't (correct me if I am wrong)
 

Speedy

Well-Known Member

Reaction score: 25
Messages: 301

Maybe there is. I recall many years ago I added a bunch of IPFIREWALL options into my kernel by hand so they got built into kernel instead of being modules. They were not in GENERIC, unfortunately I do not remember what documentation I was reading at the time.

Back to your issue, if you do not want it loaded just move it, then next boot it won't be found. Move it back if you want to use it again. Renaming it probably will work, too.
 

memreflect

Active Member

Reaction score: 157
Messages: 175

I suspect you want WITHOUT_MODULES=em, and you can use nodevice em in your kernel config instead of commenting device em; nodevice em is required if your kernel config contains include GENERIC since GENERIC on multiple architectures contains device em.

From the 8.4 The Configuration File of the FreeBSD Handbook:
An include directive is available for use in configuration files. This allows another configuration file to be included in the current one, making it easy to maintain small changes relative to an existing file. If only a small number of additional options or drivers are required, this allows a delta to be maintained with respect to GENERIC, as seen in this example:
Code:
include GENERIC
ident MYKERNEL

options IPFIREWALL
options DUMMYNET
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPDIVERT

Using this method, the local configuration file expresses local differences from a GENERIC kernel. As upgrades are performed, new features added to GENERIC will also be added to the local kernel unless they are specifically prevented using nooptions or nodevice. A comprehensive list of configuration directives and their descriptions may be found in config(5).

config(5) states that device XXXX would build support for XXXX into the kernel image, and nodevice XXXX removes support for XXXX.

make.conf(5) states that WITHOUT_MODULES prevents creation of the modules, but what it doesn't mention is that you need to use the device names in the kernel config, not the name of the resulting module (e.g. WITHOUT_MODULES=em, not WITHOUT_MODULES=if_em). I found that last bit of info through trial and error, first building using WITHOUT_MODULES=if_em (fail) and then using WITHOUT_MODULES=em (success).

I realize this is a lot of information for what are essentially two very simple changes, but I wanted to illustrate how I found that information in the first place, so that others might benefit from the process in the future.
 
Top