building kernel modules for linux differnet version

Saket Sinha saket.sinha89 at gmail.com
Tue Mar 11 13:12:51 EDT 2014


Please find my response inline

>>          I have a scenario where I need to build a driver for
>> different kernel versions.
>> I have kernel-headers of different version in /lib/modules/
>> 2.6.32-xxxx
>> 2.6.39-xxxx
>>
>> and currently I am booted into 2.6.32-xxxx(which I find out by uname -r)
>>
>
> You don't need to boot on a specific kernel version to build external
> module for it.
>

I am aware of that. I just need the kernel header of that specific
version instead.
What I meant was that since I was using the expression "uname -r" in
my makefile below-
 "make  -C   /lib/modules/$(shell uname -r)/build  M=$(PWD)  modules"
so I specified that.

>> Now in my driver makefile, I generate .ko of driver
>> make  -C   /lib/modules/$(shell uname -r)/build  M=$(PWD)  modules
>>
>> but I notice that the driver .ko gets generated for 2.6.39-xxxx though
>> I am booted into  2.6.32-xxxx. Can anyone help me figure out why this
>> is happening?
>>
>
> Could you check that /lib/modules/2.6.32-xxxx/build is not a symbolic
> link to linux 2.6.39-xxxx sources ?

I am pasting the output for you to check

[root at Noi1-502156 ~]# cd /lib/modules
[root at Noi1-502156 modules]# ls
2.6.32-220.4.2.el6.x86_64      2.6.39-300.17.1.el6uek.x86_64
2.6.32-358.6.2.el6.x86_64      2.6.39-400.24.1.el6uek.x86_64
[root at Noi1-502156 modules]# ll
total 16
drwxr-xr-x. 8 root root 4096 Feb 28 14:41 2.6.32-220.4.2.el6.x86_64
drwxr-xr-x. 7 root root 4096 Jul 15  2013 2.6.32-358.6.2.el6.x86_64
drwxr-xr-x  8 root root 4096 Aug 12  2013 2.6.39-300.17.1.el6uek.x86_64
drwxr-xr-x. 4 root root 4096 Jul 10  2013 2.6.39-400.24.1.el6uek.x86_64
[root at Noi1-502156 modules]#

Regards,
Saket Sinha



More information about the Kernelnewbies mailing list