FreeBSD comes with kldstat command. The kldstat utility or command displays the status of any files dynamically linked into the kernel. And the kldunload utility unloads a file which was previously loaded with lldload command. You can use kldunload command as follows.
Unload a file from the kernel
First login as a root user (use su - or sudo commnad):
Get list of loaded modules/drivers first use following command
# kldstat
To remove module use the following command
The kldstat utility displays the status of any files dynamically linked into the kernel.
kldunload -i ID
OR
kldunload module-name
Example to unload smbfs module
Type the following command as the root user:
# kldunload smbfs
OR
# kldunload -i 8
Please note that # 8 is module ID obtained using kldstat command.
Force the unload
You can pass -f option to kldunload to force the unload. This ignores error returns to MOD_QUIESCE from the module and implies that the module should be unloaded even if it is currently in use. The users are left to cope as best they can.
# kldunload -f smbfs
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 2 comments… read them below or add one }
Thanks. Couldn’t be clearer.
[mike@mike-pc] /home/mike# kldunload -fv -i 23 snd_hda && kldload snd_hda
Unloading snd_hda.ko, id=23
kldunload: can’t unload file: Device busy
[mike@mike-pc] /home/mike# uname -a
FreeBSD mike-pc 8.2-RELEASE FreeBSD 8.2-RELEASE #7: Wed Feb 16 13:33:10 PST 2011 root@build8x64.pcbsd.org:/usr/obj/usr/pcbsd-build82/fbsd-source/8.2/sys/PCBSD amd64