In my local Linux/Ubuntu, I have two directories for Linux src


I found the code in 3.16.0 is much more than that in 3.16.0-generic. I am wondering why and how those two directories are different (and what do they represent?)


The two directories are provided by the corresponding packages, which contain the header files for the kernel. Use dpkg command to find which package provide the directories.

$ dpkg -S /usr/src/linux*
linux-headers-X.XX.X-XX: /usr/src/linux-headers-X.XX.X-XX
linux-headers-X.XX.X-XX-generic: /usr/src/linux-headers-X.XX.X-XX-generic

The first directory /usr/src/linux-headers-X.X.XX-XX comprises header files for multiple architectures, including x86, amd64, powerpc and others, resulting in more number of files and larger size of package.

The other directory /usr/src/linux-headers-X.X.XX-XX-generic seemed to contain mostly source codes relevant to x86 architecture that is targeted for the local installation.

The corresponding package has hinted in the description, for example:

$ apt-cache show linux-headers-3.16.0-25 | grep -A3 Description-en
Description-en: Header files related to Linux kernel version 3.16.0
 This package provides kernel header files for version 3.16.0, for sites
 that want the latest kernel headers. Please read
 /usr/share/doc/linux-lts-utopic-headers-3.16.0-25/debian.README.gz for details

As far as I am aware, both directories contain only source codes and not binaries. And the difference between both is mainly the target architecture of source codes.

Related: What does a kernel source tree contain? Is this related to Linux kernel headers?

Extended answer (2015.07.30)

since both store x86 related code, what is the difference btwn the x86 code in the two directories? – Richard Jul 29 '15 at 19:11

Most of directories and files contained in /usr/src/linux-headers-X.X.XX-XX-generic are symbolic links, which pointing to actual directories and files in /usr/src/linux-headers-X.X.XX-XX. In other words, arch/x86 found in those two directories are just the difference of actual and symbolic links, with some leftover files of asm headers in *-generic counterpart.

Between those two packages, one may notice another major difference is the presence of config and generated directories in *-generic counterpart.

At my best understanding, I would think that *-generic directory holds the necessary header files for configuring and compiling modules relevant to x86 architecture, without making accidential changes to the source directory of linux-headers-x.x.xx-xx.

Above all, the two directories are probably the "clean" approach to packaging and compiling the packages on respective platforms. Although, I am not in position to clarify this matter.

  • since both store x86 related code, what is the difference btwn the x86 code in the two directories? – Richard Jul 29 '15 at 19:11
  • @Richard I have updated my answer as above at my best of knowledge, as simple as possible. My answer may be seen as naive, so you may want to look for better answer from someone else instead. – clearkimura Jul 30 '15 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.