Hello Friends
I made new simple 'Hello World' module

 *  hello-1.c - The simplest kernel module.
#include <linux/module.h>    /* Needed by all modules */
#include <linux/kernel.h>    /* Needed for KERN_INFO */

int init_module(void)
    printk(KERN_INFO "Hello world 1.\n");

     * A non 0 return means init_module failed; module can't be loaded. 
    return 0;

void cleanup_module(void)
    printk(KERN_INFO "Goodbye world 1.\n");

then i write Makefile

obj-m += hello-1.o

    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

after that i run the make command

after that insmod ./hello-1.ko
module is inserted ok
when i run cat /proc/modules
it shows that my new module is added but with (P) marked ok
when i restart my PC to see weather my module is printing ' Hello World ' or not its not res poncing any thing
when PC completely start again i run /proc/modules
then my newly added module is missing
how to add module permanently in the kernel

Edited by Nick Evan: Fixed formatting

8 Years
Discussion Span
Last Post by gerard4143
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.