I would like to know how to insert a custom kernel module into the kernel during boot time?

Also, would also like to ask how to ensure that this kernel module is always inserted earlier than all the other normal kernel modules? Or is there like a priority number to attach to this kernel module to ensure that it can be inserted into the kernel ASAP.

Thank you very much!

EDIT: managed to figure out how to insert a kernel module on boot. now figuring out how to ensure it is being inserted first

EDIT: the start up process for Ubuntu reads from etc -> run -> lib

Link to documentation: http://manpages.ubuntu.com/manpages/xenial/man5/modules-load.d.5.html

Looking at what possible start up scripts to edit to explicitly increase the priority insertion other than the ones in /etc/modules

EDIT: Have decided to modify the initramfs config file as compared to the initrd config file. Reason being that the initramfs is a root file system that we are able to built into the kernel itself and will take precedence if the file exists. Need to ensure to update the initramfs config file after each modification.

  • upvote for working it out yourself – jsotola Jul 1 at 1:34
  • @jsotola Greetings, thank you for the encouragements!! Would like to ask if I would want to include it during the boot time, I have do modify the files in /usr/src/linux-headers-3.13.0-32/scripts ? Cause I did some research and only found the /etc/modules, init and the rc.local files – user357066 Jul 1 at 3:19
  • i am not super familiar with kernel module loading ... i always have to do research before doing anything ..... i do know that some of the modules are loaded in initrd ..... do you need to load yours before initrd? .... i guess that the question is "why do you need to load your module before all of the others?" – jsotola Jul 1 at 3:49
  • Sorry for the delayed reply, but its to monitor the kernel to obtain data during boot for all the other modules that will be loaded after this particular kernel module – user357066 Jul 1 at 6:12
  • perhaps you do not need a kernel module for this .... i think that there are tools for debugging a kernel that may provide the info that you need – jsotola Jul 1 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.