KLD(4)
π KLD(4) β the kld dynamic kernel linker facility π
okay bestie, welcome to the Kernel Interfaces Manual, section 4. this is the kld page and it's genuinely iconic, like the way your kernel can just... grow new powers at runtime?? main character energy fr fr. πΈ
β¨ NAME β¨
kld β the dynamic kernel linker facility π¦
β¨ DESCRIPTION β¨
so here's the tea π«: the old LKM (Loadable Kernel Modules) facility got deprecated in FreeBSD 3.0 and above, in favor of the kld interface. and like, this new one does the same cute thing as its predecessor β it lets the system administrator dynamically add and remove functionality from a running system. no reboot, no drama. π
and it's also a huge slay for software developers, because it helps them develop new parts of the kernel without constantly rebooting to test their changes. imagine. the suffering. ended. π
various types of modules can be loaded into the system, bestie. there are several defined module types (listed below β¬οΈ) that can be added to the system in a predefined way. plus there's a generic type, for which the module itself handles loading and unloading. independent king behavior. π
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 β¨
- the iBCS2 and Linux emulators π§
kld modules are placed by default in the /boot/kernel directory, along with their matching kernel. they live together. it's giving domestic bliss. π‘
the kld interface is used through the kldload(8), kldunload(8) and kldstat(8) programs:
kldload(8)can load eithera.out(5)or ELF formatted loadable modules πkldunload(8)unloads any given loaded module β if no other module is dependent upon the given module (clingy modules stay, sorry π«Ά)kldstat(8)is used to check the status of the modules currently loaded into the system π
β οΈ BIG WARNING, PAY ATTENTION BESTIE β οΈ β kernel modules may only be loaded or unloaded if the system security level kern.securelevel is less than one. less than one. that's the rule. no cap. π
β¨ MODULE TYPES β¨
π§ Device Driver modules
new block and character device drivers may be loaded into the system with kld. and the cute part? π device nodes for the loaded drivers are automatically created when a module is loaded and destroyed when it is unloaded, by devfs(5). automatic. no manual labor. we love to see it.
you can also specify userland programs that will run when new devices become available as a result of loading modules, or when existing devices go away when modules are unloaded β by configuring devd(8). so like, you get notifications. it's giving personal assistant 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 next, bestie, iykyk π:
kldfind(2), kldfirstmod(2), kldload(2), kldnext(2), kldstat(2), kldunload(2), devfs(5), devd(8), kldload(8), kldstat(8), kldunload(8), sysctl(8)
β¨ HISTORY β¨
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. glow up of the century tbh. π
β¨ AUTHORS β¨
the kld facility was originally implemented by Doug Rabson <dfr@FreeBSD.org> ππ thank you for your service king.
β¨ BUGS β¨
okay so here's where it gets real. read carefully bestie, these are the gotchas π:
- if a module B is dependent on another module A, but is not compiled with module A as a dependency, then
kldload(8)fails to load module B β even if module A is already present in the system. π - if multiple modules are dependent on module A, and are compiled with module A as a dependency, then
kldload(8)loads an instance of module A when 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. (so like, always check the receipts π)- when system internal interfaces change, old modules often cannot detect this, and such modules when loaded will often cause crashes or mysterious failures. π not the mysterious failures. the horror.
π«Ά stay safe out there and check your dependencies fr fr.
and that's the whole page, bestie!! this one came from the <strong>Debian</strong> folks, dated <strong>January 13, 2014</strong> β so when you're reading this in the group chat at 2am, just know the vibes are preserved and the facts are all here. periodt. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1993 Christopher G. Demetriou
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms