"FATAL: Module not found error" using modprobe

164,586

Solution 1

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.

Solution 2

The best thing is to actually use the kernel makefile to install the module:

Here is are snippets to add to your 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/

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

and run depmod appropriately

Solution 3

i think there should be entry of your your_module.ko in /lib/modules/uname -r/modules.dep and in /lib/modules/uname -r/modules.dep.bin for "modprobe your_module" command to work

Solution 4

Try insmod instead of modprobe. Modprobe looks in the module directory /lib/modules/uname -r for all the modules and other files

Share:
164,586

Related videos on Youtube

Ravi Gupta
Author by

Ravi Gupta

Updated on January 12, 2020

Comments

  • Ravi Gupta
    Ravi Gupta over 4 years

    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
    
  • Ravi Gupta
    Ravi Gupta almost 14 years
    so if i put my module in /lib/modules/$(uname -r) directory then will it work??
  • che
    che almost 14 years
    @Ravi Gupta: That would be my best guess.
  • Elf King
    Elf King almost 14 years
    try putting it in /lib/modules/$(uname -r)/misc/
  • Shahbaz
    Shahbaz almost 10 years
    @RaviGupta, the kernel Makefile that you invoke to build your module, also has other targets, such as modules_install that you can use to install your module.
  • ash
    ash about 5 years
    (in other words: run sudo depmod -a)
  • personal_cloud
    personal_cloud almost 5 years
    Yeah but the options are different... how would one then do modprobe -r -q <module>?
  • igntec
    igntec about 3 years
    @Ash great tip.
  • Danijel
    Danijel about 2 years
    First do sudo depmod to re-generate the module dependencies, than modprobe your_module.