KLD(4)
๐ NAME ๐ โ KLD(4) in the Kernel Interfaces Manual
okay so bestie, meet kld: the dynamic kernel linker facility. This is the manual page for KLD(4) from the Kernel Interfaces Manual, and yes, she is a whole main character in the FreeBSD kernel world. ๐ซถโจ
โจ DESCRIPTION โจ
First things first, no cap: the LKM (Loadable Kernel Modules) facility has been deprecated in FreeBSD 3.0 and above in favor of the kld interface. ๐ Like, LKM is the ex; kld is the glow-up.
This interface, like its predecessor, allows the system administrator to dynamically add and remove functionality from a running system. โจ That's the whole vibe. This ability also helps software developers to develop new parts of the kernel without constantly rebooting to test their changes. ๐ญ literally saving them from reboot roulette.
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. ๐ iykyk.
The FreeBSD 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 Linux emulator. ๐ obsessed. 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. Bestie, here's the trio:
kldload(8)โ can load eithera.out(5)orELFformatted loadable modules. ๐งkldunload(8)โ unloads any given loaded module, if no other module is dependent upon the given module. ๐kldstat(8)โ is used to check the status of the modules currently loaded into the system. ๐ฅ
๐จ vibe check, bestie: Kernel modules may only be loaded or unloaded if the system security level kern.securelevel is less than one. No cap, that's the rule.
๐ MODULE TYPES ๐
๐ฎ Device Driver modules ๐ฎ
New block and character device drivers may be loaded into the system with kld. ๐ซถ Device nodes for the loaded drivers are automatically created when a module is loaded and destroyed when it is unloaded by devfs(4). โจ Not me loving automation.
You can specify userland programs that will run when new devices become available as a result of loading modules, or existing devices go away when modules are unloaded, by configuring devd(8). ๐ it's giving helpful configuration energy.
๐ FILES ๐
/boot/kernelโ directory containing module binaries built for the kernel also residing in the directory. ๐ฆ/usr/include/sys/module.hโ file containing definitions required to compile akldmodule. ๐/usr/share/examples/kldโ example source code implementing a samplekldmodule. ๐ธ
๐ SEE ALSO ๐
Go read these too, bestie โ they're all linked in the original and we are not skipping a single one: ๐
kldfind(2)kldfirstmod(2)kldload(2)kldnext(2)kldstat(2)kldunload(2)devfs(4)devd(8)kldload(8)kldstat(8)kldunload(8)sysctl(8)
๐ฆ HISTORY ๐ฆ
History lesson, periodt: the kld facility appeared in FreeBSD 3.0 and was designed as a replacement for the lkm facility, which was similar in functionality to the loadable kernel modules facility provided by SunOS 4.1.3. ๐ iconic lineage.
๐ AUTHORS ๐
The kld facility was originally implemented by Doug Rabson <dfr@FreeBSD.org>. ๐ซถ show some respect to the OG.
๐ BUGS ๐
Okay bestie, real talk โ these are the known bugs and gotchas, and they are not cute:
- If a module
B, is dependent on another moduleA, but is not compiled with moduleAas a dependency, thenkldload(8)fails to load moduleB, even if moduleAis already present in the system. ๐ญ - If multiple modules are dependent on module
A, and are compiled with moduleAas a dependency, thenkldload(8)loads an instance of moduleAwhen any of the modules are loaded. ๐ - If a custom entry point is used for a module, and the module is compiled as an โELFโ binary, then
kldload(8)fails to execute the entry point. ๐ kldload(8)points the user to readdmesg(8)for any error encountered while loading a module. ๐- When system internal interfaces change, old modules often cannot detect this, and such modules when loaded will often cause crashes or mysterious failures. ๐จ like, be careful.
okay bye bestie ๐ โ this page's footer says Debian, January 13, 2014, KLD(4). periodt. ๐
๐ฆ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1993 Christopher G. Demetriou
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms