I have a problem with modprobe
command... I compiled the hello world module and loaded it with insmod
, it works fine and when I do lsmod
, I can see it in the output list. But when I insert this module using modprobe
I am getting a FATAL error:
root@okapi:/home/ravi# modprobe ./hello.ko FATAL: Module ./hello.ko not found. root@okapi:/home/ravi#
Here is the module code:
#include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit);
and Makefile
obj-m += hello.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
In order to insert a new module into the kernel, execute the modprobe command with the module name. Following example loads vmhgfs module to Linux kernel on Ubuntu. Once a module is loaded, verify it using lsmod command as shown below. The module files are with .
Use the modprobe command to add or remove modules on Linux. The command works intelligently and adds any dependent modules automatically. The kernel uses modprobe to request modules. The modprobe command searches through the standard installed module directories to find the necessary drivers.
modprobe looks in the module directory /lib/modules/`uname -r` for all the modules and other files, except for the optional configuration files in the /etc/modprobe.
Description. modprobe intelligently adds or removes a module from the Linux kernel: note that for convenience, there is no difference between _ and - in module names. modprobe looks in the module directory /lib/modules/'uname -r' for all the modules and other files, except for the optional /etc/modprobe.
The reason is that modprobe
looks into /lib/modules/$(uname -r)
for the modules and therefore won't work with local file path. That's one of differences between modprobe
and insmod
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With