LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Closed Thread
  Search this Thread
Old 09-03-2014, 07:30 PM   #1
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Rep: Reputation: 3
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?
 
Old 09-04-2014, 03:25 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 09-04-2014, 02:24 PM   #3
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
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.
 
Old 09-04-2014, 03:24 PM   #4
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Why not just transfer the source code of the module to the desktop and build it there, then install it there ?
 
Old 09-04-2014, 04:49 PM   #5
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
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.
 
Old 09-04-2014, 05:07 PM   #6
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
There is a symlink to the source in '/lib/modules/3.13/source', I believe that is what it checks first.
 
Old 09-04-2014, 05:29 PM   #7
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
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.
 
Old 09-05-2014, 07:45 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 09-06-2014, 02:35 AM   #9
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by gnashley View Post
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.
 
Old 09-06-2014, 11:37 AM   #10
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Are the sources for the module completely separate from the kernel sources? Post a link to the sources for us.
 
Old 09-06-2014, 02:30 PM   #11
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
Yes. The module source is realtek module for a usb wifi dongle. Find that here.
 
Old 09-07-2014, 02:06 AM   #12
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 09-08-2014, 04:30 AM   #13
slacker_
Member
 
Registered: Aug 2013
Distribution: Arch, Debian, Slackware
Posts: 333

Original Poster
Rep: Reputation: 3
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.
 
Old 09-08-2014, 09:02 AM   #14
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
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
 
  


Closed Thread

Tags
debian, kernel, module



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
How to build a kernel driver module which works for all systms having the same kernel jaatvishal Linux - Newbie 1 01-10-2014 11:42 AM
[SOLVED] How to build module against headers that are not from the running kernel? eantoranz Programming 1 04-13-2011 06:09 PM
[Error] Kernel Module : No kernel module build environment saman007uk Debian 7 09-09-2006 06:34 PM
LXer: Howto: build Linux kernel module against installed kernel w/o full kernel source tree LXer Syndicated Linux News 0 09-03-2006 08:21 PM
Unable to build NVIDIA kernel module / determin kernel version Night Ink Fedora 2 05-31-2004 04:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 07:27 PM.

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