Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 07-13-2011, 11:44 AM   #1
LQ Newbie
Registered: May 2011
Posts: 11

Rep: Reputation: 0
Unhappy loadable kernel module (LKM) issues

hi everybody,

I tried to create a new module as given in, hello-1.c.


* 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");

and then created the Makefile as


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

and then make that... but the following errors are coming:

make -C /lib/modules/ M=/home/rajaram modules
make: *** /lib/modules/ No such file or directory. Stop.
make: *** [all] Error 2

please help me as soon as possible

thanks in advance,
Old 07-13-2011, 03:59 PM   #2
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,508
Blog Entries: 4

Rep: Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953Reputation: 2953

Well, "start at the beginning, then proceed until you get to the end, then stop." You are, obviously, at the beginning. Does this directory and path exist, or does it not? If not, then what directory should it be? Then, how did the computer come up with this name that it's asking for now?

"Elementary, my dear Watson."
Old 07-14-2011, 01:40 AM   #3
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
You will need to install the kernel headers to compile kernel modules. The directory that it is searching for will exist only after you have installed the kernel headers.
If you are running ubuntu or debian you can search for linux-headers in the package manager and install the same or run the following from the terminal

sudo apt-get install linux-headers-2.6.38 ( Or some thing similar to that).

Other distros also have similar header packages.
Old 07-26-2011, 08:11 AM   #4
LQ Newbie
Registered: Jul 2011
Posts: 15

Rep: Reputation: Disabled
Thumbs up Debugging the issue... about "make: *** /lib/modules/ No such file"

Hi Shakthi,
-> Here the error mean is that the Path you had mentioned in your Make file as "/lib/modules/$(shell uname -r)/build" is Incorrect and
-> this can be avoid by directly pointing to your Linux Kernel Dir. of any ver. like 2.6.34(what i had done). So, in this there are the libraries relating to your.

Old 07-26-2011, 09:02 AM   #5
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,705

Rep: Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294
The Fedora package name is 'kernel-devel'.

# yum install kernel kernel-devel

Then reboot to use the updated kernel and the matching development files.


kernel module, make, makefile

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Load Kernel Loadable MOdule... mohit.saha Linux - Software 3 04-18-2008 10:00 AM
I want add my own system call using LKM (loadable kernel module)... raga4223688 Linux - Software 1 03-07-2007 07:21 AM
how to insert a loadable module into the kernel.? moog Linux - Newbie 2 01-08-2007 08:37 AM
Help, loadable kernel module . ERBRMN Linux - General 3 10-13-2006 07:34 AM
loadable kernel module brajesh Linux - General 2 01-17-2003 12:54 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:28 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration