I'm curious:

What, exactly are the benefits to statically linking modules into the kernel rather than loading through rc.conf, etc?

For example:

To add Linux emulation, I could add linux_enable="YES" to /etc/rc.conf, or I could link it into the kernel by adding options COMPAT_LINUX to my kernel config.

Is there actually an advantage to this? If so, what?

2 Answers 2


Statically linking used to be the only way to load a module which is think is the primary reason to having options like COMPAT_LINUX. Also, prior to loader, it used to be the only way to load modules necessary to get FreeBSD to get the necessary drivers to mount the root file system and boot FreeBSD. Nowadays, I don't think there is any significant benefit to statically linking in a module if it can be easily loaded at runtime. I don't think you will see any benefit in performance by statically linking Linux compatibility support, but some users still swear by it. I would avoid it just because of the inconvenience of recompiling a Kernel for little to no perceived performance gain.

  • Perfect. It's what I assumed, and I'd much rather edit a conf file than recompile whenever I add new support :P Apr 20, 2011 at 19:35
  1. If you statically link everything you need you can then simply use makeoptions NO_MODULES=yes so you're not building unnecessary modules.

    This can also be accomplished with MODULES_OVERRIDE and/or WITHOUT_MODULES.

  2. The ability to load modules at runtime is not always a good thing. The module could be a rootkit for instance.

    SECURELEVEL also mitigates this.

As with these two, probably any benefit can also (and some would argue, should) be accomplished in another way.

Personally I like my kernel to be like a firewall ruleset: I start by excluding everything, then add what I need and prevent additions at runtime.

Unless the kernel is recompiled, I know exactly what is supported. So if I have not compiled in some functionality, like SCTP or NFS, I can just ignore advisories that only affect those parts. Adding functionality requires me to manually add it.

With modules there are numerous ways how a module could get loaded automatically: by simply using some functionality once, by installing a port, by updating (default changed, new functionality added), etc.

In all of those cases I think it's a benefit to be forced to manually add the functionality if, and only if, it's actually needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.