【问题标题】:"FATAL: Module not found error" using modprobe“致命:未找到模块错误”使用 modprobe
【发布时间】:2010-06-29 12:12:36
【问题描述】:

modprobe 命令有问题...我编译了 hello world 模块并用insmod 加载它,它工作正常,当我执行lsmod 时,我可以在输出列表中看到它。但是当我使用modprobe 插入这个模块时,我遇到了一个致命错误:

root@okapi:/home/ravi# modprobe ./hello.ko 
FATAL: Module ./hello.ko not found.
root@okapi:/home/ravi#

这是模块代码:

#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);

和生成文件

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

【问题讨论】:

    标签: c linux linux-kernel kernel linux-device-driver


    【解决方案1】:

    原因是modprobe 查找/lib/modules/$(uname -r) 的模块,因此不适用于本地文件路径。这是modprobeinsmod 之间的区别之一。

    【讨论】:

    • 所以如果我把我的模块放在/lib/modules/$(uname -r) 目录那么它会工作吗??
    • @Ravi Gupta:这是我最好的猜测。
    • 试着把它放在 /lib/modules/$(uname -r)/misc/
    • @RaviGupta,你调用来构建你的模块的内核 Makefile,也有其他的目标,比如你可以用来安装你的模块的modules_install
    【解决方案2】:

    最好的办法是实际使用内核makefile来安装模块:

    这是要添加到 Makefile 中的 sn-ps

    在顶部添加:

    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
    

    在结尾加上:

    install:
            $(MAKE) -C $(KERNEL_BUILD) M=$(PWD) \
               INSTALL_MOD_PATH=$(INSTALL_ROOT) modules_install
    

    然后你可以发出

        sudo make install
    

    这会将它放在 /lib/modules/$(uname -r)/extra/ 中

    或/lib/modules/$(uname -r)/misc/

    并适当地运行 depmod

    【讨论】:

      【解决方案3】:

      我认为在 /lib/modules/uname -r/modules.dep 和 /lib/modules/uname -r/modules.dep.bin 中应该有 your_module.ko 条目,用于“modprobe your_module”命令工作

      【讨论】:

      • (换句话说:运行sudo depmod -a
      • @Ash 很棒的提示。
      【解决方案4】:

      尝试insmod 而不是 modprobe。模组探针 在模块目录 /lib/modules/uname -r 中查找所有模块和其他 文件

      【讨论】:

      • 是的,但选项不同......然后modprobe -r -q &lt;module&gt;怎么办?
      【解决方案5】:

      确保在加载模块之前关闭您的网络:

      sudo stop networking
      

      它帮助了我 - https://help.ubuntu.com/community/UbuntuBonding

      【讨论】:

        【解决方案6】:
        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)
        

        After your normal make, you copy module module_name.ko into   directory  /lib/modules/<var>/extra/
        

        然后做 modprobe module_name(不带 .ko 扩展名)

        【讨论】:

          猜你喜欢
          • 2015-01-21
          • 2022-10-20
          • 2016-12-25
          • 2020-05-11
          • 2021-01-08
          • 2020-06-22
          • 1970-01-01
          • 2021-09-07
          • 2021-05-24
          相关资源
          最近更新 更多