0% found this document useful (0 votes)
68 views

How To Write A Simple Kernel Module in Linux (centOS 7)

To write a simple kernel module in CentOS 7, one must first install development tools with yum, create a directory for the project, and write a C file with init and exit functions. A Makefile is then needed to compile the C file into a KO module that can be installed and tested with dmesg to confirm loading.

Uploaded by

PRATEEK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

How To Write A Simple Kernel Module in Linux (centOS 7)

To write a simple kernel module in CentOS 7, one must first install development tools with yum, create a directory for the project, and write a C file with init and exit functions. A Makefile is then needed to compile the C file into a KO module that can be installed and tested with dmesg to confirm loading.

Uploaded by

PRATEEK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

How to write a simple kernel module in linux (centOS 7)?

STEPS:-

1) To create development environment in centOS 7

# yum group install "Development Tools"

2) Create a directory.

mkdir usr/local/src/kernel_example
cd usr/local/src/kernel_example

3)vi and create the file kernel_example.c with the following contents:

$vi kernel_example.c
We call module_init and module_exit to tell the kernel which

functions are loading and unloading functions.We can’t compile this

file yet, though.

We need a Makefile.

$vi Makefile
The resulting file is “anjali_example.ko”.
we can insert the module to test it

$sudo insmod anjali_example.ko

$ dmesg

You might also like