[英]“FATAL: Module not found error” using modprobe
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. 我有一个
modprobe
命令的问题...我编译了hello world模块并使用insmod
加载它,它工作正常,当我执行lsmod
,我可以在输出列表中看到它。 But when I insert this module using modprobe
I am getting a FATAL error: 但是当我使用
modprobe
插入此模块时,我收到一个致命错误:
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 和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
The reason is that modprobe
looks into /lib/modules/$(uname -r)
for the modules and therefore won't work with local file path. 原因是
modprobe
在/lib/modules/$(uname -r)
查找/lib/modules/$(uname -r)
,因此无法使用本地文件路径。 That's one of differences between modprobe
and insmod
. 这是
modprobe
和insmod
之间的差异之一。
The best thing is to actually use the kernel makefile to install the module: 最好的事情是实际使用内核makefile来安装模块:
Here is are snippets to add to your Makefile 以下是要添加到Makefile的片段
around the top add: 在顶部添加:
PWD=$(shell pwd)
VER=$(shell uname -r)
KERNEL_BUILD=/lib/modules/$(VER)/build
# Later if you want to package the module binary you can provide an INSTALL_ROOT
# INSTALL_ROOT=/tmp/install-root
around the end add: 最后添加:
install:
$(MAKE) -C $(KERNEL_BUILD) M=$(PWD) \
INSTALL_MOD_PATH=$(INSTALL_ROOT) modules_install
and then you can issue 然后你可以发出
sudo make install
this will put it either in /lib/modules/$(uname -r)/extra/ 这将把它放在/ lib / modules / $(uname -r)/ extra /
or /lib/modules/$(uname -r)/misc/ 或/ lib / modules / $(uname -r)/ misc /
and run depmod appropriately 并适当地运行depmod
我认为应该在/ lib / modules / uname -r
/modules.dep和/ lib / modules / uname -r
/modules.dep.bin中输入your_module.ko,以便“modprobe your_module”命令工作
Try insmod
instead of modprobe. 尝试
insmod
而不是modprobe。 Modprobe looks in the module directory /lib/modules/ uname -r
for all the modules and other files Modprobe在模块目录/ lib / modules /
uname -r
查找所有模块和其他文件
Insert this in your Makefile
$(MAKE) -C $(KDIR) M=$(PWD) modules_install
it will install the module in the directory /lib/modules/<var>/extra/
After make , insert module with modprobe module_name (without .ko extension)
OR 要么
After your normal make, you copy module module_name.ko into directory /lib/modules/<var>/extra/
then do modprobe module_name (without .ko extension) 然后做modprobe module_name(不带.ko扩展名)
Ensure that your network is brought down before loading module: 在加载模块之前确保网络已关闭:
sudo stop networking
It helped me - https://help.ubuntu.com/community/UbuntuBonding 它帮助了我 - https://help.ubuntu.com/community/UbuntuBonding
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.