Reputation: 9015
My hello world device:
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) {
printk(KERN_ALERT "hello world\n");
return 0;
}
static void hello_exit(void) {
printk(KERN_ALERT "goodbye world\n");
}
module_init(hello_init);
module_exit(hello_exit);
How can I make my driver to load automatically during start-up?
I can load it manually successfully using insmod
, but I want it to be automatically loaded after a reboot. Do I need to use Kbuild
and select it in make menuconfig
, or do we do that some other way?
Upvotes: 2
Views: 2705
Reputation: 3234
Install the module in /lib/modules/<kernel version>
Add the module name to /etc/modules
if On Debian/Ubuntu Systems or Add the module name to /etc/modules.conf
if On RH/Fedora/CentOS systems
Upvotes: 0
Reputation: 942
On systemd based systems, there is /lib/systemd/system/systemd-modules-load.service
which
[...] reads files from the above directories
which contain kernel modules to load during
boot in a static list
See here for a list of directories used by that systemd service.
You can simply add a .conf file containing the name of the module you want to load at boot. The module must be correctly installed under /lib/modules
and loadable with modprobe
.
Upvotes: 3