Howto: Build Linux Kernel Module Against Installed Kernel w/o Full Kernel Source Tree

by Vivek Gite on September 2, 2006 · 66 comments

Recently I received a question via email:

How do I build Linux kernel module against installed or running Linux kernel? Do I need to install new kernel source tree from kernel.org?

To be frank you do not need a new full source tree in order to just compile or build module against the running kernel i.e an exploded source tree is not required to build kernel driver or module. The instruction outlined below will benefit immensely to a developer and power user.

Linux Kernel headers

This is essential because if you just want to compile and install driver for new hardware such as Wireless card or SCSI device etc. With following method, you will save the time, as you are not going to compile entire Linux kernel.

Please note that to work with this hack you just need the Linux kernel headers and not the full kernel source tree. Install the linux-kernel-headers package which provides headers from the Linux kernel. These headers are used by the installed headers for GNU glibc and other system libraries as well as compiling modules. Use following command to install kernel headers:
# apt-get install kernel-headers-2.6.xx.xx.xx

Replace xx.xx with your actual running kernel version (e.g. 2.6.8.-2) and architecture name (e.g. 686/em64t/amd64). Use uname -r command to get actual kernel version name. Please note that above command will only install kernel headers and not the entire kernel source-code tree.

A more generic (recommend) and accurate way is as follows:
# apt-get install kernel-headers-$(uname -r)

All you need to do is change Makefile to use current kernel build directory. You can obtain this directory name by typing following command:
$ ls -d /lib/modules/$(uname -r)/build
Sample output:

/lib/modules/2.6.27-7-generic/build

Let, say you have .c source code file called hello.c. Now create a Makefile as follows in the directory containing hello.c program / file:
$ vi Makefile
Append following text:

obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Save and close the file. Type the following command to build the hello.ko module:
$ make

To load Linux kernel module type the command:
# modprobe hello

A complete example

Create test directory (you can download following Makefile and .c file here):
$ mkdir ~/test
$ cd ~/test

Create hello.c kernel module file:

#include
<linux/module.h>
#include
<linux/kernel.h>
 
int init_module(void)
{
	printk(KERN_INFO "init_module() called\n");
	return 0;
}
 
void cleanup_module(void)
{
	printk(KERN_INFO "cleanup_module() called\n");
}
 

Create a Makefile:

obj-m += hello.o
 
all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
 
clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clea

To build kernel module enter:
$ make
Sample output:

make -C /lib/modules/2.6.27-7-generic/build M=/tmp/test2 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.27-7-generic'
  CC [M]  /tmp/test2/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/test2/hello.mod.o
  LD [M]  /tmp/test2/hello.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-7-generic'

Run ls command to see newly build kernel module:
$ ls
Sample output:

hello.c  hello.ko  hello.mod.c	hello.mod.o  hello.o  Makefile	Module.markers	modules.order  Module.symvers

hello.ko is kernel module file. To see information about module, enter:
$ modinfo hello.ko
Sample output:

filename:       hello.ko
srcversion:     4F856ABA1F3290D5F81D961
depends:
vermagic:       2.6.27-7-generic SMP mod_unload modversions 586 

To load kernel module, enter:
$ sudo insmod hello.ko
OR
$ sudo modprobe hello
To list installed Linux kernel module, enter:
$ lsmod
$ lsmod | grep hello

To remove hello Linux kernel module, enter:
$ rmmod hello
This module just logs message to a log file called /var/log/messages (/var/log/syslog), enter:
$ tail -f /var/log/messages
Sample output:

Nov  5 00:36:36 vivek-desktop kernel: [52488.923000] init_module() called
Nov  5 00:36:50 vivek-desktop kernel: [52503.065252] cleanup_module() called

Download above examples in zip format

See a detailed and completeexample with C source code about Compiling Linux kernel module for more information.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 65 comments… read them below or add one }

1 chesss September 3, 2006

would this work with suspend2 patching as well?

Reply

2 Anonymous September 4, 2006

This is untrue, /lib/modules/$(shell uname -r)/build is a symlink to the source tree. Title is misleading, you always need the at least the headers to build kernel modules.

Reply

3 zhangmaike September 4, 2006

on my system, /lib/modules/KERNELVERSION/build is a symlink to the corresponding full source tree.

Reply

4 nixcraft September 7, 2006

Yes you need kernel headers but not source code from kernel.org (45+ MB tar ball). So title and post is correct.

Reply

5 nixcraft September 7, 2006

You should have mentioned your distro name. I have tested this on Red Hat, Cent OS, FC and Debian and it works perfectly.

On some distro it makes a soft link to kernel header to /usr/src/version but you don\’t need source code. Just delete rest of linux kernel source code (except for headers). And try out this hack

Reply

6 s.kartikeyan September 8, 2006

probably kernel-devel*.rpm is required in addition to makefile
using /lib/modules.

Reply

7 Jon Eastwood January 30, 2007

You are 100% correct – you require the kernel headers
whereas the source code from kernel.org is not required.

Reply

8 Frank June 4, 2007

Here’s one for you… I have a network interface that I need to re-compile every time the kernel is updated. This is for the realtek 8169 NIC.
Any way to automate this task on a yum update of a kernel?

If you are running the target kernel, then you should be able to do :

# make clean modules (as root or with sudo)
# make install
# depmod -a
# insmod ./src/r8169.ko

You can check whether the driver is loaded by using following commands.

# lsmod | grep r8169
# ifconfig -a

If there is a device name, ethX, shown on the monitor, the linux
driver is loaded. Then, you can use the following command to activate
the ethX.

# ifconfig ethX

,where X=0,1,2,…

If I go though this process on the local box after a kernel upgrade, I’m good to go, but it sucks that I have to do this..

Thanks,
Frank.

Reply

9 Alexander Mestiashvili June 20, 2007

this Makefile did not work for me .
i used this one


obj-m += hello-1.o

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

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

Reply

10 Daniel October 26, 2007

This is not clear enough for linux beginners. I am so sad that google placed this page so high in rankings.

Maybe you should try to make it a bit easier to understand (give more details or explain why you do that ‘hello.c’ thing).

Sincerely,
Dan

Reply

11 vivek October 26, 2007

Daniel,

You need to see hello.c (module) example here.

HTH

Reply

12 almassian February 18, 2008

I don’t know how can I built a makefile?!
where should I define the PWD??!
please help me, I’m a beginner :D :-p

Reply

13 Alien Glow September 18, 2008

I fumbled every time trying to install kernel modules on Debian. Though someone might find this useful. I have picked this bits from different sources.

Compile and install a Kernel Module in Debian
KVER=$(uname -r | sed ‘s,-.*,,g’)

aptitude install linux-headers-$(uname -r) linux-source-$KVER build-essential
cd /usr/src
tar jxf linux-source-$KVER.tar.bz2
ln -s /usr/src/linux-source-$KVER /lib/modules/$(uname -r)/source

Download the required module source and unpack it
Enter module source directory
make
make install
To make the module visible to your running kernel, you may like to run
depmod -a
modprobe modulename

Reply

14 touristguy87 November 4, 2008

SOP is to follow the instructions line by line from beginning to end to make sure that they actually work before posting them as a “guide”.

There are too many holes here.

a) you don’t need to know exactly what verion of the kernel you have, $(uname -r) takes care of that for you.

b) what’s the difference beween $(uname -r) and $(shell uname -r)?

c) what about includes like #include etc that I see on the reference pages, here?

“See a detailed and complete example with C source code – how to Compiling Linux kernel module for more information.”

That code doesn’t work either. I can’t get the includes to work. If I hardcode them then they just reference other header files that don’t link properly because they have includes written the same way. I can’t even get that example to build.

Reply

15 touristguy87 November 4, 2008

that is to say
#include

..where exactly is this file?

It’s in /lib/modules/$(uname -r)/build/include right? (I found it, I’m doing this from memory at 3am last night) ok so I hardcode that into the #include above and then I just get a bunch of errors saing that linux/whatever.h can’t be found so clearly in that header file are similar #includes.

I modified the PATH variable to include /lib/modules…include and that still doesn’t work. I guess that I’ll figure this out later and post a solution.

Reply

16 vivek November 4, 2008

touristguy87,

Under Ubuntu Linux 8.x install the following package (following will almost install every kernel source code file):

sudo apt-get install linux-headers-$(uname -r) linux-libc-dev kernel-package

Once done create hello.c as follows:
mkdir ~/hello
cd ~/hello

Create hello.c:

#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
	printk(KERN_INFO "init_module() called\n");
	return 0;
}
void cleanup_module(void)
{
	printk(KERN_INFO "cleanup_module() called\n");
}

Create Makefile (note tabs are important):

obj-m += hello.o
all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Type following to build:
make
Sample output from my Ubuntu 8.10 box:

make -C /lib/modules/2.6.27-7-generic/build M=/tmp modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.27-7-generic'
  CC [M]  /tmp/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/hello.mod.o
  LD [M]  /tmp/hello.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-7-generic'

HTH

Reply

17 touristguy87 November 6, 2008

ok then I would just remove this part from the above:

# apt-get install kernel-headers-2.6.xx.xx.xx

as to just use $(uname -r) is much better

also any comments about having to change to the “build” directory

and note that you have to use $(shell uname -r) in the makefile.

likewise do you need linux-libc-dev or not, it sounds redundant…

and there is now a zip file with the programs, and two other links as examples.

this one is probably redundant now except for it points to the original instructions on how to do this…and a lot more.

http://www.tldp.org/LDP/lkmpg/2.6/html/hello2.html

http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html

thanks

Reply

18 touristguy87 November 7, 2008

ok also

obj := vs obj +=

at the top it is the former, the working code seems to be the latter

Here I also see
http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html

obj-m = foo.o
KVERSION = $(shell uname -r)

and the orignal source:
http://www.tldp.org/LDP/lkmpg/2.6/html/hello2.html

has +=

this is pretty simple code once you’ve looked at it for 2 hours ;)

I think the main thing is that it has to point to $(uname -r)/build but you have to use $(shell uname -r) in the makefile -C part.

anyway I see plenty of variation in the basic syntax among the 5 or 6 examples on those 3 links.

Reply

19 vivek November 7, 2008

Use method which works for you. There is also 3rd method but I don’t wanna confuse you with more stuff. Yes, linux-libc-dev is not required until and unless you are going to play more with low level device driver and other stuff requiring functions from libc.

HTH

Reply

20 touristguy87 November 8, 2008

I got it, somehow. I don’t know how.

I was getting the “can’t find target ‘make’ error”…I updated my system and rebooted and just tried make on a whim and it worked.

I used $(shell uname -r) in the Make file and += for the labels

also I removed the function-calls from the code.See the original example here:

http://www.tldp.org/LDP/lkmpg/2.6/html/hello2.html

Reply

21 sathish November 13, 2008

what is use of .mod.o and .mod.c files , the Makefile which is present in o.s is creating , what info those files are having

Reply

22 instruc January 6, 2009

Great content tips .All you need to do is customize them with your own …Thank you…

Reply

23 ycdtosa January 19, 2009

if build is missing (even after installing headers) this might help:

ln -s /usr/src/linux-headers-$(uname -r) /lib/modules/$(uname -r)/build

Reply

24 kyle Locke January 29, 2009

Thanks. Its what I was searchin for.

Reply

25 anon February 5, 2009

Anonymous 09.04.06 at 1:09 am wrote:
>This is untrue, /lib/modules/$(shell uname -r)/build is a symlink to the source tree.

build is a symlink to the build environment. Since source trees are build environments too, the build symlink can also point to them. But where just a plain build env without source is present, build points to a directory which merely has
total 556
drwxr-xr-x 6 root root 110 Feb 4 12:24 .
drwxr-xr-x 4 root root 27 Jan 30 21:39 ..
drwxr-xr-x 3 root root 16 Feb 4 12:24 arch
drwxr-xr-x 5 root root 55 Feb 4 12:24 include
drwxr-xr-x 2 root root 16 Feb 4 12:24 include2
drwxr-xr-x 6 root root 116 Feb 4 12:24 scripts
-rw-r–r– 1 root root 89994 Jan 30 21:42 .config
-rw-r–r– 2 root root 530 Jan 30 21:43 Makefile
-rw-r–r– 1 root root 474571 Jan 30 21:39 Module.symvers

Reply

26 m.h February 24, 2009

about the first module “hello.c ” , I had a problem ,
I installed my kernel headers but after “make” I was recieved this message …
Nothing to be done for ‘default’
and the second one as well ….
Nothing to be done for ‘all’

what shall I do ?

Reply

27 kim gomez June 15, 2009

It was interesting to read trough :-) keep up the good work and thanks for all the tips.

Reply

28 kim gomez June 15, 2009

Can you provide more information on this, or do you have some resources you can share where i can get more of such stuff?

Reply

29 sharath August 14, 2009

THANK YOU VERY MUCH FOR HELPING BEGINNERS

Reply

30 saju August 17, 2009

ERROR-1:
periyar:/home/saju/Desktop/hello-linux-module# apt-get install kernel-headers-$(uname -r)
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package kernel-headers-2.6.26-1-686
——————————————–
ERROR-2 in Debian Lenny.
periyar:/home/saju/Desktop/hello-linux-module# make
make -C /lib/modules/2.6.26-1-686/build M=/home/saju/Desktop/hello-linux-module modules
make: *** /lib/modules/2.6.26-1-686/build: No such file or directory. Stop.
make: *** [all] Error 2

Reply

31 Vivek Gite August 17, 2009

install kernel-headers package using yum (Fedora / RHEL CentOS) or apt-get (Debian/Ubuntu).

Reply

32 saju August 18, 2009

I solved first Error by #apt-get install linux-headers
But the second error not solved . Please help

periyar:/home/saju/Desktop/hello-linux-module# make
make -C /lib/modules/2.6.26-1-686/build M=/home/saju/Desktop/hello-linux-module modules
make[1]: Entering directory `/lib/modules/2.6.26-1-686/build’
make[1]: *** No rule to make target `modules’. Stop.
make[1]: Leaving directory `/lib/modules/2.6.26-1-686/build’
make: *** [all] Error 2

Reply

33 Benno September 10, 2009

Great tutorial. Thanks!

Reply

34 Rohit October 14, 2009

Its a wonderful introduction to a fresher to Linux.
Thanks I was frustated when I found that makefile should be “Makefile” !!!!!!!!

Reply

35 Joe October 15, 2009

What if the hello.c is actually a hello.cpp ? How do we do the Makefile for that?

Reply

36 baskar November 24, 2009

I tried this on CentOS5.4 and I cannot proceed after this:

[cuser@localhost test]$ make
make -C /lib/modules/2.6.18-164.el5/build M=/home/cuser/test modules
make: *** /lib/modules/2.6.18-164.el5/build: No such file or directory. Stop.
make: *** [all] Error 2

But, I do have kernel-devel and kernel-headers.

[cuser@localhost test]$ yum search kernel-headers kernel-devel
Loaded plugins: fastestmirror
============================ Matched: kernel-devel =============================
kernel-devel.x86_64 : Development package for building kernel modules to match
: the kernel.

=========================== Matched: kernel-headers ============================
kernel-headers.x86_64 : Header files for the Linux kernel for use by glibc
[cuser@localhost test]$

Could you help? If I figure this out, I can install the Broadcom BCM4312 wireless driver for Linux by Broadcom where I have the same issue.

Thanks a lot

Reply

37 Viper December 11, 2009

Ubuntu 9.10 x64

headers, source, module-assistant, build-essential, all installed.

Typing “make -C /lib/modules/$(uname -r)/build M=$(pwd) modules”
Get the following error:

make: Entering directory `/usr/src/linux-headers-2.6.31-16-generic’
make: *** No rule to make target `para’. Stop.
make: Leaving directory`/usr/src/linux-headers-2.6.31-16-generic’

Typing just “make”, adds
make: *** [default] Error 2
to the above

Any comment?

Reply

38 touristguy87 December 12, 2009

a) read all of the above
b) make sure that your OS is fully up to date

Trust me, this does work.

Reply

39 Viper December 12, 2009

All was read. OS is up to date.

But I solved it. Problem was the folder had a space in the name. Replaced with an underscore and it worked.

Reply

40 netbrat February 5, 2010

help me how should i get rid of this error

sudo make
make -C /lib/modules/2.6.31-19-generic/build M= modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.31-19-generic’
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
make[2]: *** No rule to make target `kernel/bounds.c’, needed by `kernel/bounds.s’. Stop.
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.31-19-generic’
make: *** [all] Error 2

Reply

41 Vlad June 21, 2010

I found an error in Makefile:

$(PWD) should be $(shell pwd)

Since PWD is not defined, I think it attempts to compile the entire kernel source.
It solved this error I got:
“make[2]: *** No rule to make target `kernel/bounds.c’, needed by `kernel/bounds.s’. Stop.”

Reply

42 steven March 3, 2011

i’m actually compiling a different kernel module and i came across this comment. it fixed my compilation errors.

thanks so much!

Reply

43 Louise Doogan March 26, 2011

Hi netbrat,

I am getting the same error using Ubuntu version 2.6.24-19-generic. Did you get to the bottom of this? I am pulling my hair out!!

Reply

44 Sumathi Gopal February 9, 2010

Thank you for this. It worked like a charm. I’m on a Ubuntu laptop with 2.6.28-11 kernel installation; no kernel source code.

-sumathi

Reply

45 touristguy87 February 11, 2010

…in response to the numerous messages that I get about this, yes: Linux development is not as “tight” as I would like it to be. There will be little errors here and there, that you have to figure out and fix. It’s not “plug and chug”.

But that’s part of its charm. If you’re just a *little* bit intelligent, you can read the errors and figure out what the problem is without knowing exactly what the errors mean. You get a feel for it. All of these bright linux coders don’t want to waste their time going back and documenting and correcting and redocumenting every problem that they have fixed. So sometimes some slip through.

…remember, you’re getting their code for free. You might have to work with it a little.

Or you can buy everything that you need from MS or some other major vendor and when you run into bugs with *that* you can pay for a support-incident and wait for them to fix it right :) Which is not an entirely bad idea as Linux is not as robust as Windows when it comes to things like copying files. It’s fairly easy to screw a file with the Ubuntu desktop, if you’re not careful.
It’s not perfect. It’s just good, and free. But I wouldn’t, and I can’t, put 100% of my effort into Ubuntu/Linux.

That’s why I have two laptops. One that runs Ubuntu and Vxbox, and the other that runs xp32sp3. You get stuck on one, just work on the other until you figure it out. Eventually you will figure it out, and learn a lot in the process. And it will help if you ask a specific question and not just copy and paste error messages onto this forum and then say “help me!”. Most errors are variations on a basic theme: some format error, a version-incompatibility or a file that is not where the tool in question thinks that it should be or maybe it doesn’t contain what that tool thinks that it should have. Try to actually read the documentation for the tools that you work with. And then just hope that the documentation is correct :)

Basically you have one big advantage. 9 times out of 10 the code is right there, all you have to do is open it up and read it, and figure out how it works. There may be small bugs. You might have to fix them. Really that’s not very likely if the above is taken care of. But it’s not impossible. And if that’s too much trouble, write to the developer and ask for help, or just find another tool that does what you need, that actually works. Or another way to do what you need to do. That’s only limited by you.

cheers

Reply

46 linux April 5, 2010

I dont have much examples to practice on.. Can you provide some examples to try on? (I have tried examples from LKMPG).

Reply

47 Joerg April 15, 2010

Could you clarify:

(Ubuntu 9.10)
I have linux-headers-x.x.x-y in my /usr/src directory. Are they the same as kernel-headers? (I find no kernel-headers anywhere on the machine, and as to apt-getting them, see below).
- They (the linux-headers) contain a Makefile, can one do the procedure from within there?
- If yes, there are “linux-headers-x.x.x-y” and “linux-headers-x.x.x-y-generic”, the latter with links. Which one (generic I suppose)?

And one more question:
apt-get install kernel-headers-$(uname -r) gives me:
E: Couldn’t find package kernel-headers-2.6.31-20-generic

Thanks for enlightening me, Joerg

Reply

48 touristguy87 April 30, 2010

Hint to all before you post in this list:

before you post in this list

BEFORE you post in this list

go to this link:

http://www.google.com

See the little box there?
Take your question and/or comment and put it in there. See what happens.
You just might find your answer there!

This page is not Google. It seems that many have confused the two. You will not find the answer to all of your questions here. You just might find them on Google!

Reply

49 woNelly May 27, 2010

A little bitter that people are finding your post and actually trying what you said? If you give a quick tutorial and people have a question on YOUR tutorial, why should they expect google to answer?

Reply

50 touristguy87 May 27, 2010

No, I’m annoyed by people who insist on posting stupid thoughtless comments like yours.
You epitomize the problem.

Linux is not exactly the most straightforward, logical, and debugged OS that there is out there. But people like you who write first and then think second (if ever, and certainly not well) just make the situation worse. Maybe it hasn’t occurred to you yet but people who know what they are doing don’t want to help people like that because they don’t want to deal with them. You can’t expect someone to help you with every fucking question that you might have about anything they say, no matter how stupid your question is or how easily it would be answered if you would just use either your brain or Google not to mention both. People do not exist to help nitwits like you stumble through life.

Reply

51 touristguy87 March 3, 2011

..in other words, why should you expect *anyone* to answer?
And what if they don’t? Or their answer is wrong?

What if, in the end, your brain is the only thing standing between you and utter failure?

Would you then quit and blame the world for your problems?
Or would you actually think and maybe think hard and long but keep thinking and trying until you come up with a solution?

And if in the end, you do that, why would people not say “well it would be nice if you would just do that normally”?

I’m not saying that that’s the right attitude especially in a help file.
But if the difference between self-sufficiency and helplessness is 5 minutes of thought?
Do you really want to make a habit of taking 30 seconds to type a question vs 5 minutes to think through all the options on your own?

Anyway having seen this thread two dozen times long after I finished with it I would still have to look at my original posts and say that the answer was not found solely in this example. I had to pull up many pages on the same topic and try to get the examples to work there..and when I did so I found out many things which helped me to get this to work. This was definitely not the answer all on its own.

Yes, Linux sucks that way. It’s definitely true.

But it can be done and thus the bar exists between the self-sufficient and the overly-dependent who hire them and pay them to do IT work.
That’s just how it is.
And were it not that way, Linux software would probably not be open nor would it be so advanced. You’d probably still have software repositories with freeware and shareware but it would be the same crap that you can get for Windows. Instead of having a multitude of development in Linux that is eventually ported over to Win32/64 and made available for free, you’d get a bunch of time-limited shareware crap that is just a copyright-infringement on some expensive proprietary package and very little if any real development would happen in the user-space. We’d be stuck in 1995 and MS would still rule the PC market.

It is that very arrogance and standoffishness that has helped to free MS users from their chains.
Without it there would be no competition and no real freedom of choice in the mainstream market.
And you can’t have your cake and eat it at the same time.
Face it: the guys who really know their shit are far too busy to help newbies who can’t be bothered to take the time and make the effort to think on their own, not to mention who lack the intellect to do so effectively.
And for very good reason. They are too smart to let themselves get dumbed down to the point of ineffectiveness.

And if you think that it is bad here, try going to college and asking your professors stupid questions and see how well that works. No one owes you any explanation for anything and they certainly are not going to waste their time and energy giving you an endless series of explanations. Indeed many people will happily say nothing and let you suffer, just for the entertainment-value that you present to them. Of course you may not like that, you may even resent that, but believe me they probably don’t like you and certainly resent you as well. They will definitely resent doing your thinking for you and having you benefit as a result instead of them.

And there are a lot of people in this world who walk around expecting people to help them regardless of how stupid or lazy they are. That’s just not a good way to go through life. Eventually someone will make you pay for it. And pay badly…pay in ways that you have yet to even imagine. And then blame you for being stupid enough to get in that position when the real fact is that they merely took advantage of you. That’s not really going to help you when you are the one lying there curled up in pain, even more helpless than before, and they are walking away laughing and counting your money.

The key to happiness in life is self-sufficiency not a support-network.

Reply

52 Guillaume May 28, 2010

Well I found this page using google which make your comment recursively irrelevant

Reply

53 touristguy87 June 1, 2010

only if you *really* have a poor grasp of logic, and believe that this page is the only thing that you can find using Google.

Reply

54 embedded_user June 21, 2010

Hi.

Thank you for the examples and explanations.

I had a particular question and wanted to ask here- I did try and google for my answer in various ways, but I did not find any clear answers.

I have an embedded linux device running 2.6.28 on ARMv6-compatible processor rev 6 (v6l).

I don’t have access to the kernel, but the ntfs.ko is being loaded as a module and is in a directory where I can alter it.

The ntfs.ko loaded for the device does not permit read/write access- just read only.

The device does not have any package loaders, (no apt-get).

I have an ubunutu install and could run commands from there (though your article seems to imply you would be working with the headers on the actual/running kernel) or is it possible for me to get/install the headers on the embedded machine without apt-get?

Anyway, thanks for your hard work,
embedded_user

Reply

55 michi84 August 19, 2010

Remember once again: Certain lines within the shown Makefile have to be indented by TABs, _not_ SPACES, so a simple copy&paste won’t do it and leads to the rather meaningless error message: “make: Nothing to be done for `all’.”

Reply

56 samuel October 2, 2010

in Ubuntu 10.04, it’s not
# apt-get install kernel-headers-$(uname -r)
it’s
# apt-get install linux-headers-$(uname -r)

Reply

57 James February 5, 2011

Thank you for this tutorial. It helped. Immensely.

Reply

58 The Asylum April 26, 2011

Downloading with Axel (for me) is more consistent. It hits about 775-785 kb/s and stays there throughout the entire download.

Wget fluctuates from as high as 790 kb/s to as low as 50 kb/s, and every number in between.

The only real flaw with Axel is an easy fix but one that should be made default. The actual terminal output. There is an alternative output that keeps your download progress to a single line, but someone new probably wont find it.

Reply

59 Basil June 3, 2011

Hi Vivek,

Thanks for the post. I have to compile a module on my VPS that run centOS 32 bit. The folder /lib/modules/ is empty. I looked for the build file on /usr/src/ and other folders on server without luck.

Could you please shed some light on this..?

Basil

Reply

60 Jalal Hajigholamali June 7, 2011

Hi,

Very useful material

Reply

61 Robert Zaleski June 8, 2011

This is not clear enough for linux beginners.

Uhmmm, writing a kernel module is the last thing you should be doing as a beginner. If you’re just compiling one, then it depends heavily on the module you are compiling, and the documentation from that module writer is what you should go by. If they don’t have good instructions on how to compile and install, I’d be super hesitant to use it.

Overall, I thought this was super helpful. I almost had to stop and make the sample module and load it just to do it :)

Reply

62 ender ossel June 11, 2011

i have not a /var/log/messages how can i read the output of my helloworld kernel module? :-)

Reply

63 ARSHABBIR August 15, 2011

USE dmesg

Reply

64 jalal hajigholamali August 16, 2011

thanks, very useful materi

Reply

65 cap10ibraim October 5, 2011

Thanks , works on Ubuntu lucid 10.04

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 10 + 15 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: