Skip to main content


Showing posts from January, 2010

Implementing a new system call in Kernel version 2.6.32

A system call is used by application or user programs to request service from the operating systems. Since the user programs does not have direct access to the kernel whereas the OS has the direct access. OS can access the hardware through system calls only.The following files has to be modified for implementing a system call/usr/src/linux- set of files to be createdCreate a new directory newcall/ inside the path “/usr/src/linux-” Create new files Makefile, newcall.c and put them in the /usr/src/linux- folder Create new user files (in any folder of Linux) to test the system call
testnewcall.c, testnewcall.h (created in /home/pradeepkumar) syscall_table_32.S Find the file /usr/src/linux- and add the following line at the end

How to add a new Linux Kernel Module (LKM)

To demonstrate, let us goto a simple “Hello World” as a module and inserted in to the kernel

Step 1
Open any editor like vi or gedit in a shell prompt and the type the following
/* Name of the file is hello.c */
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
printk(KERN_INFO “Hello world.n”);
return 0;
void cleanup_module(void)
printk(KERN_INFO “Goodbye worldn”);

The above is a simple C program that displays “Hello world” when the module is inserted and displays “Goodbye world” when the module is removed.
Step 2
The program can be compiled using gcc compiler in the shell prompt itself, but we need to write the commands twice or more. So to compile shortly let us write a makefile to compile the above program
The make file should be named as Makefile (See the First letter M is uppercase and there should not be any space between Make and file)
Copy and paste the following lines in an editor (vi or gedit)
obj-m += hello.o
make -C /lib/modules/$(shell uname -r…

Recompiling Linux Kernel

How to add a new kernel to linux OS and compile it and use it, the following points discusses that.
Step 1: Download a new kernel from (recent version is 2.6.33)
Step 2: you may get the file either as a .tar.bz2 file  or .tar.gz file
Step 3: untar the file in the /usr/src directory (for installing you need to be a root user)
if it is a bz2 file, then execute tar jxvf filename.tar.bz2 –C /usr/src
if it is a gz file, then execute tar zxvf filename.tar.gz –C /usr/src
Step 4: go to the folder /usr/src using the command cd /usr/src

Step 5: Execute the following 
Execute any one of the following commandmake config (for text mode) make menuconfig make xconfig (for X window) make gconfig (this command is preferred) Step 6: make  (will take atleast 30 minutes to complete, be patient)
Step 7: make modules
Step 8: make modules_install
Step 9: make install
Once done, reboot the system, your grub loader is updated with one more kernel.
(NB: in the previous flavors of linux, the following are the s…