FreeBSD: Load Kernel Module at Runtime

Posted on in Categories , , last updated July 29, 2013

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
OR
# 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 and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Leave a Comment