FreeBSD: Load Kernel Module at Runtime

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

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsFreeBSD
TimeLess than a minute
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.

ADVERTISEMENTS

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.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.