LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   How can you build a kernel module for a kernel that isn't running on your system? (https://www.linuxquestions.org/questions/general-10/how-can-you-build-a-kernel-module-for-a-kernel-that-isnt-running-on-your-system-4175517319/)

slacker_ 09-03-2014 07:30 PM

How can you build a kernel module for a kernel that isn't running on your system?
 
I have been searching for hours trying to find any guides or information in general for how to build a kernel module for a kernel I am not currently running.

The situation I'm in is as follows:

I am running debian stable (kernel 3.2 x64) on my laptop, and I am trying to build a kernel module for a desktop running an ubuntu variant called Zorin (kernel 3.13 x32). The reason I am building it on my laptop is because the desktop in question has no internet access and this module will solve that problem.

So, how can I build this module for the 3.13.0-32 kernel if I'm running 3.2.04-amd64 kernel?

gnashley 09-04-2014 03:25 AM

The kernel or module you are compiling has no relation to the running kernel. You simply need to use the sources for the kernel version you are compiling for.

slacker_ 09-04-2014 02:24 PM

Ok, could you tell me how to do that? When I've tried to compile this module, it just builds it for the kernel I currently have which I have the source for as well obviously. I have the source for the 3.13 kernel, but I don't know how to tell 'make' to use the 3.13 source.

metaschima 09-04-2014 03:24 PM

Why not just transfer the source code of the module to the desktop and build it there, then install it there ?

slacker_ 09-04-2014 04:49 PM

I tried that, and it kept failing with "make[2] (path to source) Error 1" or "make[1] (path to source) Error 2" so the easiest method I could think to do it was to build it with the 3.13 source on my laptop. But I can't figure out how to do this without the module building for the kernel I am currently using. I have the source for 3.13 in /usr/src, but when I run make it still only builds for the kernel I am currently running.

metaschima 09-04-2014 05:07 PM

There is a symlink to the source in '/lib/modules/3.13/source', I believe that is what it checks first.

slacker_ 09-04-2014 05:29 PM

Thay still doesn't help me understand what I need to do to have the make command see that symlink, or see 3.13 at all.

gnashley 09-05-2014 07:45 AM

Usually, /usr/src/linux is a symlink to the sources for the running version and some module sources will look there first for the kernel sources. Some sources let you specify the pathh to the kernel sources to use. If your code does not, then changing the /usr/src/linux link to püoint to the desired sources should work. The sources may need to be pre-configured in order to build your module.

slacker_ 09-06-2014 02:35 AM

Quote:

Originally Posted by gnashley (Post 5232699)
The sources may need to be pre-configured in order to build your module.

What do you mean by this? Like I said this whole process is new to me so I'm sort of like a half blind person feeling their way through a topiary maze.

gnashley 09-06-2014 11:37 AM

Are the sources for the module completely separate from the kernel sources? Post a link to the sources for us.

slacker_ 09-06-2014 02:30 PM

Yes. The module source is realtek module for a usb wifi dongle. Find that here.

gnashley 09-07-2014 02:06 AM

You need to edit the Makefile starting at line 200 to set the path to the kernel sources and to the module sources (as part of following the directions in the file README_STA_usb.

slacker_ 09-08-2014 04:30 AM

Just loaded Zorin in a VM to build the module then copy it over to the destination machine, but it errored (see here).

In the morning I will try to explicitly set path to kernel and such on my main system (not VM) and see if that works.

jeremy 09-08-2014 09:02 AM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

http://www.linuxquestions.org/questi...em-4175517399/

--jeremy


All times are GMT -5. The time now is 02:03 PM.