Howto: Build Linux Kernel Module Against Installed Kernel w/o Full Kernel Source Tree
2013-02-26 11:50
615 查看
http://www.cyberciti.biz/tips/build-linux-kernel-module-against-installed-kernel-source-tree.html
Howto: Build Linux Kernel Module Against Installed Kernel w/o Full Kernel Source Tree
by NIXCRAFT on SEPTEMBER2, 2006 · 68
COMMENTS· LAST UPDATED NOVEMBER
4, 2008
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
Download fileSee a detailed and completeexample with C source code about Compiling Linux kernel module for more information.
Tweet
You should follow me on twitter here or grab rss
feed to keep track of new changes.
Featured Articles:
30 Handy Bash Shell Aliases For Linux / Unix / Mac OS XTop 30 Nmap Command Examples For Sys/Network Admins
25 PHP Security Best Practices For Sys Admins
20 Linux System Monitoring Tools Every SysAdmin Should Know
20 Linux Server Hardening Security Tips
Linux: 20 Iptables Examples For New SysAdmins
Top 20 OpenSSH Server Best Security Practices
Top 20 Nginx WebServer Best Security Practices
20 Examples: Make Sure Unix / Linux Configuration Files Are Free From
Syntax Errors
15 Greatest Open Source Terminal Applications Of 2012
My 10 UNIX Command Line Mistakes
Top 10 Open Source Web-Based Project Management Software
Top 5 Email Client For Linux, Mac OS X, and Windows Users
The Novice Guide To Buying A Linux Laptop
{ 67 comments… read them below or add
one }
1chesss September
3, 2006 at 9:12 pm
would this work with suspend2 patching as well?
REPLY
2Anonymous September
4, 2006 at 1:09 am
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
3zhangmaike September
4, 2006 at 2:28 am
on my system, /lib/modules/KERNELVERSION/build is a symlink to the corresponding full source tree.
REPLY
4nixcraft September
7, 2006 at 12:22 pm
Yes you need kernel headers but not source code from kernel.org (45+ MB tar ball). So title and post is correct.
REPLY
5nixcraft September
7, 2006 at 12:23 pm
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
6s.kartikeyan September
8, 2006 at 2:14 am
probably kernel-devel*.rpm is required in addition to makefile
using /lib/modules.
REPLY
7Jon
Eastwood January 30, 2007 at 12:12 pm
You are 100% correct – you require the kernel headers
whereas the source code from kernel.org is not required.
REPLY
8Frank June
4, 2007 at 9:58 pm
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
9Alexander
Mestiashvili June 20, 2007 at 12:48 pm
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
10Daniel October
26, 2007 at 10:06 pm
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
11vivek October
26, 2007 at 10:16 pm
Daniel,
You need to see hello.c (module) example here.
HTH
REPLY
12almassian February
18, 2008 at 11:19 am
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
13Alien
Glow September 18, 2008 at 5:40 am
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
14touristguy87 November
4, 2008 at 5:49 pm
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
15touristguy87 November
4, 2008 at 5:52 pm
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
16vivek November
4, 2008 at 6:52 pm
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
17touristguy87 November
6, 2008 at 6:04 pm
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
18touristguy87 November
7, 2008 at 4:12 am
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
19vivek November
7, 2008 at 7:03 am
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
20touristguy87 November
8, 2008 at 7:03 am
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
21sathish November
13, 2008 at 9:36 am
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
22instruc January
6, 2009 at 5:14 pm
Great content tips .All you need to do is customize them with your own …Thank you…
REPLY
23ycdtosa January
19, 2009 at 11:42 am
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
24kyle
Locke January 29, 2009 at 7:30 am
Thanks. Its what I was searchin for.
REPLY
25anon February
5, 2009 at 5:12 pm
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
26m.h February
24, 2009 at 8:11 am
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
27kim
gomez June 15, 2009 at 4:13 am
It was interesting to read trough :-) keep up the good work and thanks for all the tips.
REPLY
28kim
gomez June 15, 2009 at 4:16 am
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
29sharath August
14, 2009 at 2:47 pm
THANK YOU VERY MUCH FOR HELPING BEGINNERS
REPLY
30saju August
17, 2009 at 1:17 pm
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
31Vivek
Gite August 17, 2009 at 2:25 pm
install kernel-headers package using yum (Fedora / RHEL CentOS) or apt-get (Debian/Ubuntu).
REPLY
32saju August
18, 2009 at 10:04 am
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
33Benno September
10, 2009 at 3:15 am
Great tutorial. Thanks!
REPLY
34Rohit October
14, 2009 at 7:19 pm
Its a wonderful introduction to a fresher to Linux.
Thanks I was frustated when I found that makefile should be “Makefile” !!!!!!!!
REPLY
35Joe October
15, 2009 at 9:00 am
What if the hello.c is actually a hello.cpp ? How do we do the Makefile for that?
REPLY
36baskar November
24, 2009 at 11:22 pm
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
37Viper December
11, 2009 at 1:34 am
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
38touristguy87 December
12, 2009 at 7:57 am
a) read all of the above
b) make sure that your OS is fully up to date
Trust me, this does work.
REPLY
39Viper December
12, 2009 at 11:52 am
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
40netbrat February
5, 2010 at 10:24 pm
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
41Vlad June
21, 2010 at 6:51 pm
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
42steven March
3, 2011 at 6:00 pm
i’m actually compiling a different kernel module and i came across this comment. it fixed my compilation errors.
thanks so much!
REPLY
43Louise
Doogan March 26, 2011 at 1:48 am
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
44Sumathi
Gopal February 9, 2010 at 7:20 am
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
45touristguy87 February
11, 2010 at 4:30 pm
…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
46linux April
5, 2010 at 5:55 pm
I dont have much examples to practice on.. Can you provide some examples to try on? (I have tried examples from LKMPG).
REPLY
47Joerg April
15, 2010 at 1:07 pm
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
48touristguy87 April
30, 2010 at 10:19 pm
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
49woNelly May
27, 2010 at 2:33 pm
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
50touristguy87 May
27, 2010 at 4:35 pm
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
51touristguy87 March
3, 2011 at 10:19 pm
..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
52Kyle
Jones February 23, 2012 at 11:45 pm
That was the best reply ever. I read your article, thought, “yeah, that’s cool, make using the right headers, easy enough. Wow, didn’t know you could make a module that small, neat.” Then I read the comments and wondered what the heck these beginners were trying
to do messing with kernel module development, and specialized build processes. It just seemed silly. Good on you for saying it like it is :-)
REPLY
53Guillaume May
28, 2010 at 6:39 pm
Well I found this page using google which make your comment recursively irrelevant
REPLY
54touristguy87 June
1, 2010 at 1:27 am
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
55embedded_user June
21, 2010 at 5:42 pm
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
56michi84 August
19, 2010 at 6:50 pm
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
57samuel October
2, 2010 at 1:01 am
in Ubuntu 10.04, it’s not
# apt-get install kernel-headers-$(uname -r)
it’s
# apt-get install linux-headers-$(uname -r)
REPLY
58James February
5, 2011 at 7:24 pm
Thank you for this tutorial. It helped. Immensely.
REPLY
59The
Asylum April 26, 2011 at 8:05 pm
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
60Basil June
3, 2011 at 1:28 pm
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
61Jalal
Hajigholamali June 7, 2011 at 3:09 am
Hi,
Very useful material
REPLY
62Robert
Zaleski June 8, 2011 at 1:24 pm
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
63ender
ossel June 11, 2011 at 10:24 am
i have not a /var/log/messages how can i read the output of my helloworld kernel module? :-)
REPLY
64ARSHABBIR August
15, 2011 at 6:07 am
USE dmesg
REPLY
65jalal
hajigholamali August 16, 2011 at 4:37 pm
thanks, very useful materi
REPLY
66cap10ibraim October
5, 2011 at 9:10 am
Thanks , works on Ubuntu lucid 10.04
REPLY
67Airead
Fan July 5, 2012 at 6:12 am
works on Ubuntu 12.04
# uname -r
Linux airead 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
REPLY
相关文章推荐
- Howto: Build Linux Kernel Module Against Installed Kernel w/o Full Kernel Source Tree
- Build linux kernel Module
- Linux kernel source build error
- linux mint Unable to build kernel module. See log file /tmp/vmware-root/modconfig
- How to Compile Linux Kernel from Source to Build Custom Kernel
- Add kernel module to Linux/Android kernel srouce code tree.
- linux里面编译安装显卡驱动失败:ERROR:Unable to find the kernel source tree for the currently running kernel.
- Build linux kernel Module
- Building a Linux kernel module without the exact kernel headers
- Radix Tree in Linux Kernel
- HOWTO: install kernel debuginfo packages on SUSE Linux Enterprise Server 11
- The Linux Kernel Module Programming Guide(hello)
- Read Linux Kernel Source Code 0.12
- The Linux Kernel Module Programming Guide
- The Linux Kernel Module Programming Guide
- Android Studio开启虚拟机遇到HAX kernel module is not installed问题
- Build Linux Kernel
- 線上 Android/Linux Kernel Source Code瀏覽 - Android/Linux Source Code Cross Reference
- 修改内核时候总是遇到make: ***/root/build_kernel/linux-2.6.14.1/arch/arm 是一个目录.停止的错误
- Linux kernel module symbols relocation