The LKM (Loadable Kernel Modules) facility has been deprecated in
.Fx 3.0 and above in favor of the kld interface. This interface, like its predecessor, allows the system administrator to dynamically add and remove functionality from a running system. This ability also helps software developers to develop new parts of the kernel without constantly rebooting to test their changes.
Various types of modules can be loaded into the system. There are several defined module types, listed below, which can be added to the system in a predefined way. In addition, there is a generic type, for which the module itself handles loading and unloading.
.Fx system makes extensive use of loadable kernel modules, and provides loadable versions of most file systems, the NFS client and server, all the screen-savers, and the iBCS2 and Linux emulators. kld modules are placed by default in the /boot/kernel directory along with their matching kernel.
The kld interface is used through the kldload(8), kldunload(8) and kldstat(8) programs.
The kldload(8) program can load either a.out(5) or ELF formatted loadable modules. The kldunload(8) program unloads any given loaded module, if no other module is dependent upon the given module. The kldstat(8) program is used to check the status of the modules currently loaded into the system.
Kernel modules may only be loaded or unloaded if the system security level kern.securelevel is less than one.