I'm trying to get a kernel module to load at boot.

If I run insmod /path/to/module.ko, it works fine. But this has to be repeated every time I reboot.

If I run modprobe /path/to/module.ko, it can't find the module. I know modprobe uses a configuration file, but I can't get it to load the module even after adding /path/to/module.ko to /etc/modules.

What is the proper configuration?

share|improve this question
up vote 52 down vote accepted

You can make a symbolic link of your module to the standard path, so depmod will see it and you'll be able load it as any other module.

sudo ln -s /path/to/module.ko /lib/modules/`uname -r`
sudo depmod -a
sudo modprobe module

If you add the module name to /etc/modules it will be loaded any time you boot.

Anyway I think that the proper configuration is to copy the module to the standard paths.

share|improve this answer
4  
If you really want, you can write "search /some/other/path" to /etc/depmod.conf or /etc/depmod.d/something, but I'd still suggest doing as Jaime suggested and copying or symlinking to /lib/modules/uname -r, where everybody expects modules to be. – ephemient Oct 22 '08 at 14:52
    
you can also rewrite include/config/kernel.release and recompile kernel. Your modules then will be in /lib/modules/<whatever-you-wrote-to-kernel.release>/ – yaccz Nov 16 '13 at 8:54
1  
I just had to scracth my head a bit, until I discovered, that I was under /lib/modules/ of wrong kernel version. So indeed, use that uname -r, at least to verify current kernel version... – hyde Nov 5 '14 at 16:29

I think the key is to copy the module to the standard paths.

Once that is done, modprobe only accepts the module name, so leave off the path and ".ko" extension.

share|improve this answer

Follow following steps:

  1. Copy hello.ko to /lib/modules/'uname-r'/misc/
  2. Add misc/hello.ko entry in /lib/modules/'uname-r'/modules.dep
  3. sudo depmod
  4. sudo modprobe hello

modprobe will check modules.dep file for any dependency.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.