LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Building new kernel in /usr/src/linux is WRONG? (https://www.linuxquestions.org/questions/linux-software-2/building-new-kernel-in-usr-src-linux-is-wrong-92495/)

jisse 09-13-2003 07:17 PM

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!

harrygraham 09-13-2003 09:44 PM

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

mlp68 09-13-2003 10:21 PM

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

jisse 09-14-2003 04:57 AM

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.


All times are GMT -5. The time now is 11:20 PM.