BSD Newsletter.com
   Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·Advocacy
·Drivers
·Events
·Flavours
·FAQs
·Guides
·Programming
·Security
·Software
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/View__44___load__44___or_unload_a_kernel_module.html.

View, load, or unload a kernel module

Concept

Undertand the difference between a statically compiled kernel and one that uses loadable kernel modules. Be able to view, load and unload kernel modules on each BSD system but should be aware that kernel modules are discouraged on NetBSD and OpenBSD systems.

TODO: Are they really discouraged? Where documented?

Introduction

Kernel modules provide extra functionality that a system administrator can add to their running kernel. Common examples include audio device drivers, network interfaces, RAID and other hardware drivers, extra filesystems support, packet filtering, binary compatibility support for other operating systems (like Linux), and console screen savers. In most cases, this extra functionality or hardware support can be configured and then built in to your monolithic kernel. But using kernel modules may be more convenient.

On FreeBSD and DragonFly, the kernel module filenames have an .ko extension. NetBSD and OpenBSD kernel modules end with .o.

On FreeBSD, the default kernel modules are located at /boot/kernel. DragonFly's kernel modules are located in the /modules directory. NetBSD's kernel modules are at /usr/lkm. TODO: And OpenBSD

TODO: list a few common modules TODO: show how to find modules

FreeBSD and DragonFly use kldload, kldunload, and kldstat to load, unload and to view details, respectively. NetBSD and OpenBSD use the modload, modunload, and modstat tools.

Examples

The following is an example of runninng kldstat to list modules on a DragonFly system:

# kldstat
Id Refs Address    Size     Name
1    5 0xc0100000 5eff14   kernel
2    1 0xc06f0000 2b58     ecc.ko
3    1 0xc06f3000 591d0    acpi.ko
4    1 0xdd68c000 3000     null.ko

The "refs" column shows the number of modules referenced by the kernel object. TODO: The "address" column shows the load address of (the pointer to) the kernel object. The "size" is the size in hexadecimal.

In the above examples, "ecc" is for AMD64 ECC memory controller, "acpi" is for ACPI power management, and "null" provides the mount_null filesystem support.

TODO: explain why the kernel listed

TODO: should this mention -v? maybe not for BSDA?

Practice Exercises

More information

kldstat(8), kldload(8), kldunload(8), and loader.conf(5); modstat(8), modload(8), modunload(8), and lkm.conf(5)



Front | Information | Lists | Newsfeeds