[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: kernel source location



Russell <rjshaw@iprimus.com.au> [2002-08-31 19:02:36 +1000]:
> In my debian 3 system, i've got no /usr/src/linux directory
> or symlink. In what situations do i need the kernel source
> here?

None unless you _want_ to put things there.

> Do the 'generic' kernel compiling/installation instructions such
> as at http://www.tldp.org/HOWTO/Kernel-HOWTO.html apply ok to
> a debian system?

If you wish to install a kernel using the generic instructions you may
do so.  You can unpack the kernel in /usr/src/linux and rebuild there.
At that point your system will resemble a linux-from-scratch system
for that particular piece of it.  That is probably okay.

I personally prefer to keep the package management software in the
process so that when I upgrade kernels it will remove any obsoleted
files.  The from scratch process won't do that automatically.  I
prefer the maximum in trackability and system robustness.  But on
development systems I will hack and slash too if that makes sense at
the time.

> Do i need /usr/include/linux and /usr/include/asm ?

Yes.  Some source code will reference it.  But most importantly libc
will reference it internally to other headers in /usr/include.

> Do they need to be the same version as the currently running kernel?

No.  Unless you are changing an program ABI the kernel is mostly
backward compatible and therefor as long as the interface is
compatible they don't need to match.

> (i think on other systems these are provided in the kernel source
> directly)

That has been the traditional linux method.  But it does not have to
be that way.  And that way has problems.  /usr/src is a source
development area.  /usr/include is an area for installed files, not
development files.  People doing development in /usr/src can easily
break compilation of programs using /usr/include.

Therefore after development of files in /usr/src they are installed
for production use in /usr/include.  At least that is one methodology.
Rather like developing in unstable and then releasing to stable.  This
is the default for Debian.  It makes the system more robust.

But on your system you can customize it however you like.

> I found some interesting things from
>   http://www.opensound.com/linux-x86.html :
> 
>  The problem under Debian and SuSE is that the linux kernel is
>  not installed under /usr/src/linux - so you just need to ensure
>  that /usr/src/linux links to the directory containing the Linux
>  kernel sources. Additionally, Debian and SuSE ships with
>  /usr/include/linux and /usr/include/asm that are directories
>  that are the header files that are used to build Debian or SuSE.
>  These technically should be the header files from the kernel
>  source tree so you really have to remove these directories and
>  link /usr/include/linux and /usr/include/asm to the kernel
>  source directory. Please follow the steps below. 
> 
>    ln -s /usr/src/linux-x.x.x /usr/src/linux (where x.x.x is the kernel version,
>      eg: ln -s /usr/src/linux-2.2.17 /usr/src/linux)
>    mv /usr/include/linux /usr/include/linux.orig
>    mv /usr/include/asm /usr/include/asm.orig
>    ln -s /usr/src/linux/include/linux /usr/include/linux
>    ln -s /usr/src/linux/include/asm /usr/include/asm

On Debian the files in /usr/include/{asm,linux} are provided in the
libc6-dev package.  That is the installed file location of kernel
headers.  IIRC it follows the FHS which I believe would be violated if
you were really pointing off to /usr/src although I will admit to not
looking up the docs at this moment.

When I started using debian Lamont passed along these instructions to
me on one method to rebuild the kernel.  Everyone has personal
preferences and different users will suggest different methods.  YMMV.
I have tweaked these instructions so any errors are my own.

  1) apt-get install kernel-source-2.4.18 kernel-package
  2) cd /usr/src
  3) tar xjf kernel-source-2.4.18.tar.bz2
  4) cd kernel-source-2.4.18
  5) cp /boot/config-whatever .config
  6) make menuconfig or whatever...
  7) make-kpkg --revision rwp.1 binary-arch
  8) cd ..
  9) dpkg -i *rwp.1_i386.deb

  s/2.4.18/current.kernel.revision/g
  s/rwp/your-login/g

HTH
Bob

Attachment: pgp6z3xprhTZY.pgp
Description: PGP signature


Reply to: