LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-13-2003, 08:17 PM   #1
jisse
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: rh/debian
Posts: 43

Rep: Reputation: 15
Building new kernel in /usr/src/linux is WRONG?


Okay, somebody mentioned the following paragraph in the README file of the kernel source:
"Do NOT use the /usr/src/linux area! This area has a (usually incomplete) set of kernel headers that are used by the library header files. They should match the library, and not get messed up by whatever the kernel-du-jour happens to be."
Linus Torvalds seems to have said the same.

Now, almost every distribution seems to advise otherwise. They all say: "Copy your new kernel source into /usr/src/linux and compile it". The warning would make sense to me if you would compile a new kernel and wait for a year to use it. You could bump into the problem that library header files (like used by modules) need some reference in /usr/src/linux which is now being changed.

But I guess most users recompile their kernel to add new features they want to use right away: So we compile our kernel, place in into the boot directory, recompile our modules, reboot and we're running with the new features we want.

I guess things go wrong if you forget to recompile your modules while running a new kernel. But in most cases the version mismatch between old modules and the new running kernel is bigger than the version mismatch between old modules and the new kernel source (compiled and well).

Light my fire!
 
Old 09-13-2003, 10:44 PM   #2
harrygraham
Member
 
Registered: Apr 2001
Location: Ottawa, Canada
Distribution: Mint Cinnamon AMD64
Posts: 155

Rep: Reputation: 18
Cool soft links

If you are just trying to reconfigure your present kernel, then you can use the linux@ directory. But before you create the new kernel, edit the Makefile to something different than the present kernel settings or it will write over top of your old modules.

"/usr/src/linux" is really a soft-linked directory to a real directory. So if you are unpacking the source for a newer kernel, it will make a second directory beside the one that came from your installation CD's. In the case below, the linux-2.4.8 is the present kernel source and linux-2.4.22 is the newer source you have downloaded. But linux@ is still linked to linux-2.4.8 so you can't use it.

Your /usr/src might look like this:

linux@ linux-2.4.8 linux-2.4.22 /RPM

Since you cannot link linux@ to more than one directory, you must remove linux@ by entering the command (as root)

rm linux

next:

ln -s linux-2.4.22 linux

This will make linux@ linked to the new source directory.

Now you can use the linux@ for compiling your new kernel.

Hope this helps,

Harry

Last edited by harrygraham; 09-13-2003 at 10:48 PM.
 
Old 09-13-2003, 11:21 PM   #3
mlp68
Member
 
Registered: Jun 2002
Location: NY
Distribution: Gentoo,RH
Posts: 332

Rep: Reputation: 32
One of these urban legends...

Under kernel 2.2.x it was partly true that you could screw up things because the compiler would have the /usr/src/linux/.... in its include path, and a gross version mismatch could get you in trouble. 2.4.x captures its headers under /lib/modules/<version>/build/include, so this is no longer a problem. It is a good idea to make a paralle kernel tree and do the symlink if you get a new kernel so you can go back quickly.

mlp
 
Old 09-14-2003, 05:57 AM   #4
jisse
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: rh/debian
Posts: 43

Original Poster
Rep: Reputation: 15
Thanks mlp68. Your answer explains it all. I never looked into /lib/modules/<version>/build before. So that's what's eating my disk space .

About the symlink: Mostly I fool around with both a stable kernel (2.4) and a development kernel (2.5), so I use the symlink trick all the time. But I never ran into troubles when having no "/usr/src/linux" directory. Now I know I don't need one.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
kernel compile - no /usr/src/linux dir epoo Linux - General 2 02-18-2004 10:33 PM
Kernel Compiling not possible, Directory /usr/src/linux-2.4 isn't there rover Linux - Software 4 09-24-2003 09:05 AM
kernel recompilation: /usr/src/linux orca Linux - Distributions 5 03-04-2003 09:53 AM
Creating /usr/src/linux-<xx> from kernel.<xx>.src.rpm jmourik Linux - Newbie 2 02-19-2003 04:24 PM
no kernel in usr/src/Linux elite Linux - General 11 10-28-2002 06:10 AM


All times are GMT -5. The time now is 06:49 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration