Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a custom module at the boot time in Ubuntu?

I created a custom and simple module named Hello.ko I install the module with the command "insmod hello.ko", I check it with "dmesg" and it's working, but when I restart the system, I have to load it manually. So, how can I do for loading my custom module automatically, and where do I have to put the hello.ko? After loading the module, I would like to show the message Hello World until I press the Enter Key. Can anybody help me?

like image 690
Gonzalo Avatar asked Dec 04 '10 22:12

Gonzalo


People also ask

How do I load a kernel module on startup?

Linux config file to load a kernel module You need to edit the file named /etc/modules or put a new config file in /etc/modules-load. d/ directory. Use any one of the methods for loading kernel modules. The configuration file consists of a set of lines.


2 Answers

This technique didn't work on Ubuntu 13.10. So after a few trial and error tries I ended up with this:

Copy my kernel module to the drivers directory.

$ sudo cp mymodule.ko /lib/modules/$(uname -r)/kernel/drivers/

Add the simple name of my module to the file /etc/modules. You can edit the file or just append to it as shown here.

$ echo 'mymodule' | sudo tee -a /etc/modules

Update the list of module dependencies.

$ sudo depmod

Reboot the computer and voila, it worked.

like image 57
Bob Enohp Avatar answered Sep 24 '22 22:09

Bob Enohp


Add the module to the /etc/modules file.

And then put the module in your /lib/modules/kernelname catalogue.

like image 33
Swind Avatar answered Sep 25 '22 22:09

Swind