Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-13-2008, 09:43 AM   #1
Registered: Aug 2008
Location: India, Kerala
Distribution: openSUSE 11
Posts: 46

Rep: Reputation: 15
Smile Where to install and hack on the source


Before i go into my actual question please clear the following doubt:

When i install the linux distribution does the linux source gets installed at /usr/src/linux ?

Going into the real question:

I found this passage in one of the linux books:

Where to Install and Hack on the Source

The kernel source is typically installed in /usr/src/linux. Note that you should not use this source tree for development. The kernel version that your C library is compiled against is often linked to this tree. Besides, you do not want to have to be root to make changes to the kernel.Instead, work out of your home directory and use root only to install new kernels. Even when installing a new kernel, /usr/src/linux should remain untouched.
I did not get the real meaning of this passage.
Can anyone please explain to me in detail the meaning of this? I have just started with studying the kernel and i think the meaning of the above passage will be very useful.

Old 09-13-2008, 10:49 AM   #2
LQ Newbie
Registered: Mar 2006
Location: Norway
Distribution: Debian Etch, HP nc6320 laptop
Posts: 23

Rep: Reputation: 15
First: The only distribution I have any practical experience with is Debian.

The source code for the kernel, when downloaded and installed, will normally reside in a subdirectory of /usr/src. The subdirectory will carry the name of the kernel version, e.g. 'linux-2.6.26'. As kernel development proceeds you may choose to download the source code for a newer version, which will then be put in another subdirectory, e.g. 'linux-2.6.27'.

When you choose to build a new kernel from the source, you create a symbolic link to the subdirectory with the source code for the kernel version you wish to build, like so:

ln -s /usr/src/linux-2.6.26 linux
Now you have a directory named /usr/src/linux and you don't need to worry about getting version names mixed up. When you decide to build a newer version all you do is delete the symbolic link:

rm /usr/src/linux
and then create a new symbolic link to the kernel source directory of your choice.

Of course, you have to actually download and install the source code first. It doesn't automatically get installed (in Debian, at least).

Now, the book passage you refer to is basically saying:

"Don't mess with kernel source in the directory where you keep the source that will actually be compiled and built. Do the dirty work in your home directory so you're sure you don't mess up your system with some potentially bad code. Always be sure you have the original and untouched code available in /usr/src/linux."

Hope this helps!

Last edited by corgi; 09-13-2008 at 10:53 AM.
Old 09-13-2008, 01:17 PM   #3
Senior Member
Registered: Nov 2006
Distribution: Debian Squeeze SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
When you choose to build a new kernel from the source, you create a symbolic link to the subdirectory with the source code for the kernel version you wish to build, like so:
In fact, it's much easier than that. Just do nothing. In Debian, you do not need a link to /usr/src/linux. You might even find that it's more convenient to have your source kernels somehere else; say on a different drive. Any package that needs to use the kernel headers should be looking in /lib/modules/<kernel version>/source, which will point to the actual source used to build the running kernel.


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
LXer: Hack Your Media Player - Neuros OSD Open Source Media Player LXer Syndicated Linux News 0 01-21-2008 06:40 AM
Manual nvidia install needs kernel source, unable to select source in YOU sirius57 Linux - Hardware 2 12-04-2007 06:11 PM
DDOS/Hack? Need help to intepret and hunt source Swakoo Linux - Security 13 04-13-2006 07:17 AM
Upgrading OpenSSL rpm install to a source install userini Linux - Software 3 06-05-2004 11:23 AM
Apache source code hack - Server response headers 2.0.49 fireman949 Linux - Software 2 05-24-2004 11:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:32 PM.

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