Welcome to the new Linux Foundation Forum!

Doubt in linux file management?

chekkizharchekkizhar Posts: 182

Hai,

Am using slackware,fedora. In both cases , there are two dirs,

1. /usr/src/linux-{Kernerl version}/

2. /lib/modules/{kernel-version}/

what is the difference b/w these two? Actually , these two dir content are totally different, I agree. But, which one is the Kernel source ? :huh:

For writing device drivers, I am using the second one. But, actually, the first one only is in "src" dir .

I am not sure , this question is meaningfull or not, may this is so naive. But , want to know the difference. thank you

Comments

  • mfillpotmfillpot Posts: 2,180
    /usr/src/linux-{version} is where the linux kernel source code is stored for you to make new modules or compile a new kernel.

    /lib/modules is where your compiled kernel modules are stored to be used by your system, if you make a custom kernel this directory will only contain the modules that you have selected as modules in the kernel configuration.
  • chekkizharchekkizhar Posts: 182
    got it. thank you fillpot. :-)
  • atreyuatreyu Posts: 216
    linustorvalds wrote:
    Hai,

    Am using slackware,fedora. In both cases , there are two dirs,

    1. /usr/src/linux-{Kernerl version}/
    2. /lib/modules/{kernel-version}/


    what is the difference b/w these two? Actually , these two dir content are totally different, I agree. But, which one is the Kernel source ? :huh:

    For writing device drivers, I am using the second one. But, actually, the first one only is in "src" dir .

    I am not sure , this question is meaningfull or not, may this is so naive. But , want to know the difference. thank you
    Just to be clear, in Fedora, the kernel source (packaged in kernel-devel or kernel-PAE-devel) is installed to:

    /usr/src/kernels/{kernel_version}/

    and like mfillpot said, the kernel modules, etc. are installed to:

    /lib/modules/{kernel_version}/

    In this directory is a directory named "source" which is actuall a symbolic link to "build" in the same dir and "build" is actually a symbolic link to the above kernel source dir (/usr/src/kernels/{kernel_version}/).
  • marcmarc Posts: 647
    The kernel source can be wherever you want.

    The modules, on the otherhand, must be in /lib/modules (or you symlink/hardlink it somehow)

    Regards
  • chekkizharchekkizhar Posts: 182
    thanks Marc and atreyu .

    @ atreyu : " In this directory is a directory named "source" which is actuall a symbolic link to "build" in the same dir and "build" is actually a symbolic link to the above kernel source dir (/usr/src/kernels/{kernel_version}/). "

    Having a Kernel Source is optinal[ I guess]. If that is true, If I dont have kernel source, where these symlinks in lib/modules points to?
    And, as Matt told, if we change modules[load/unload], those changes will be in "lib/modules" ,If they are symlinks, will it affect[it has to, I think], the ORIGINAL Kernel source ?
  • marcmarc Posts: 647
    You only need the kernel sources if you are compiling modules for it ( Nvidia drivers or Vritualbox are good examples for things you need the kernel sources)

    /lib/modules does not change because of loading or unloading modules, at all. That's only the place to look upon for modules to load, that's all. Loading a modules reads it from disk, that is /lib/modules, and loads it into memory. When unloading... you get the thing, right? ;)

    As for the symlinks: you can have symlinks pointing nowhere.

    You can check where a symlink is pointing to with
    ls -l
    

    Regards
  • chekkizharchekkizhar Posts: 182
    When unloading... you get the thing, right?
    ya got it.
    you can have symlinks pointing nowhere
    yes. so, if i dont have Kernel source also, it will simply points to a location.;)
    ls -l

    ya. thanks marc
Sign In or Register to comment.