3

I have a 3rd party library which provides a kernel module (module.ko) and is required to be loaded automatically on bootup. However, module.ko is not tied to a specific version of the Linux kernel and can work across many versions. Note I do not have the source for module.ko; it comes precompiled.

I am creating an RPM package for this 3rd party library and therefore creating a SPEC file.

My first approach was to use lib/modprobe.d, lib/modules-load.d and lib/modules/$(uname -r) to automatically load module.ko on bootup. This works fine; however, I do not want to have to reinstall my package every time I upgrade the Linux kernel. This is because, in the SPEC file, module.ko is copied to lib/modules/$(uname -r), where $(uname -r) is the current kernel version.

The second approach is to create a service that loads the kernel on bootup using insmod. This avoids modprobe altogether, as modprobe requires the kernel to be copied to lib/modules/$(uname -r).

My question is whether the second approach is the only way to achieve this, or if there is a better one?

1
  • 1
    The insmod approach looks to be the easiest one.
    – Serge
    Jun 16, 2016 at 3:17

1 Answer 1

2

Instead of a service to do the insmod you could provide a /lib/modprobe.d/mymodule.conf with the line

install mymodule insmod /path/to/mymodule.ko

I tried this and it worked ok on a fedora 22 using as an example the existing slip module.

$ cd /lib/modules/4.2.8-200.fc22.x86_64/extra/drivers/net/slip/
$ lsmod|grep slip
$ sudo modprobe slip
$ lsmod|grep slip
slip                   20480  0
slhc                   20480  1 slip
$ sudo rmmod slip
$ lsmod|grep slip
$ sudo mv slip.ko.xz ~
$ sudo modprobe slip
modprobe: ERROR: could not insert 'slip': Unknown symbol in module, or unknown parameter
$ sudo sh -c 'echo install slip insmod /home/meuh/slip.ko.xz >/lib/modprobe.d/mymodule.conf'
$ sudo modprobe slip
$ lsmod|grep slip
slip                   20480  0
slhc                   20480  1 slip
3
  • Thank you for the suggestion, however this is what I tried in approach 1. The problem I found is to call /lib/modprobe.d/mymodule.conf you need to call modprobe mymodule, and to call modprobe mymodule you need mymodule.ko to be copied over to lib/modules/$(uname -r) which is what I am trying to avoid.
    – inhwank
    Jun 17, 2016 at 0:03
  • I just tried my suggestion and it worked ok. See my updated answer. Note that the .conf calls insmod not modprobe.
    – meuh
    Jun 17, 2016 at 16:19
  • Thanks for your answer, I followed your steps and it worked! I must have done something wrong before...
    – inhwank
    Jun 20, 2016 at 6:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .