FreeBSD: Load Kernel Module at Runtime

last updated in Categories , ,

How do I load a kernel module at runtime from a shell prompt under FreeBSD UNIX operating systems?

You need to use the kldload utility loads file.ko into the kernel using the kernel linker. /boot/kernel directory containing loadable modules. Modules must have an extension of .ko. The kldload utility exits 0 on success, and >0 if an error occurs.

Example: Load module called foo

Type the command as follows:
# kldload foo
# kldload -v foo
To list loaded module use kldstat as follows:
# kldstat
Some modules such as pf, ipfw, ipf, and others may be automatically loaded at boot time when the corresponding rc.conf statement is used. Modules may also be auto-loaded through their addition to loader.conf file.

kldload command options

From the man page:

     -n      Don't try to load module if already loaded.

     -v      Be more verbose.

     -q      Silence any extraneous warnings.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):