FreeBSD: How to unload (remove) device driver (module) from kernel?
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
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- FreeBSD Load Device Driver / Kernel Module
- Howto: Prevent a Linux kernel module from auto loading
- FreeBSD: How To List Device Drivers ( modules ) Loaded In Memory
- Programming Tutorial: How To Write a FreeBSD Kernel Module ( Driver )
- Linux device driver tutorial using kernel driver frameworks
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: device_driver, freebsd_remove_driver, freebsd_unload_module, kldstat_command, kldunload_command, sudo_command



Thanks. Couldn’t be clearer.