35

I have a third party module to go with a frame grabber. I've downloaded the kernel source, followed the vendor's instructions to compile it, and have the resulting module, arvdrv.ko, sitting in a folder.

The vendor has supplied a script that loads the module into the kernel and it works when I run it; the module is loaded but only until the next boot. The script does not use modprobe. I can access the frame grabber when the module is installed.

It appears to me that modprobe maintains a list of many modules. One can edit /etc/modules to add a module name and it will load at boot but the module arvdrv is not in modprobe's list.

My question is how to let modprobe know of the module? Does it need to be copied to a new location and if so where?

2
  • I finally found that the problem I had after finding the "correct" way was that the vendor forgot to include an additional initialization script so the driver loaded at boot but failed. Jun 12, 2013 at 15:45
  • Here is a quick overview of the out-of-tree module installation procedure without the automatic startup install part: stackoverflow.com/questions/22783793/… Nov 6, 2018 at 9:31

1 Answer 1

49

Using sudo:

  1. Edit the /etc/modules file and add the name of the module (without the .ko extension) on its own line. On boot, the kernel will try to load all the modules named in this file.

  2. Copy the module to a suitable folder in /lib/modules/`uname -r`/kernel/drivers. In my case this was /lib/modules/`uname -r`/kernel/drivers/pci. This will place the module in modprobe's database. I don't know if this can be a link.

  3. Run depmod. This will find all the dependencies of your module.

  4. At this point, I rebooted and then run lsmod | grep module-name to confirm that the module was loaded at boot.

See the man pages for modprobe, lsmod, and depmod for more information.

5
  • 4
    I did follow your instructions but nothing worked until the vendor supplied some debugged code!!! Your answer is complete, simple, and I believe it would have worked had there not been vendor errors. Yes, I will accept it. Jul 13, 2014 at 15:21
  • 3
    Very helpful. I'd add that in 2020 (from what version?), one can (should?) add the module(s) in a .conf file, in /etc/modules-load.d/, instead of /etc/modules.
    – Déjà vu
    Aug 4, 2020 at 5:31
  • I am stuck at step 2: what do you mean by "suitable folder"? I built a simple .ko module, but I don't know where to copy it, nor what the command you provided in step 2 means.
    – Danijel
    Dec 2, 2021 at 9:01
  • What does this command do: /lib/modules/`uname -r`/kernel/drivers?
    – Danijel
    Dec 2, 2021 at 9:02
  • OK, I got it: uname -r prints the kernel release number, in fact it gives you the right folder in the /lib/modules/ where you need to copy your .ko kernel module file.
    – Danijel
    Dec 2, 2021 at 9:14

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