Ubuntu – Where is the installed kernel source located
kernelsourcesource code
I have installed kernel source with
sudo apt-get install linux-source -y
Now, where is the source located?
Best Answer
The kernel source code installed by the linux-source package is installed in the form of a compressed archive in the /usr/src directory. For example, if you are running Ubuntu 14.04 LTS, the kernel source archive will be at /usr/src/linux-source-3.13.0.tar.bz2. You can unpack the source code in your current directory wherever you like to view it with
tar jxf /usr/src/linux-source-3.13.0.tar.bz2
If instead you would like to know how to get and prepare the kernel source for building your own custom kernel, see the Ubuntu help document on compiling your own kernel or these other questions and answers:
I think --kernel-dir is not a placeholder to replace with something. It is a parameter to the build.sh to specify kernel dir.
The kernel dir is /lib/modules/$(uname -r)/build. (The uname -r defines the installed kernel details.)
Source packages provide you with all of the necessary files to compile or otherwise, build the desired piece of software.
It consists, in its simplest form, of three files:
The upstream tarball with .tar.gz ending
A description file with .dsc ending. It contains the name of the package, both, in its filename as well as content (after the Source: keyword).
A tarball, with any changes made to upstream source, plus all the files created for the Debian package.
This has a .debian.tar.gz (source format : 3.0)
or a .diff.gz ending (source format : 1.0)
It's quite the same for Ubuntu, and in your case:
"linux-lts-vivid-3.19.0": the actual kernel, patched starting from the upstream tarball "linux-lts-vivid_3.19.0.orig.tar.gz" with the modifications listed in "linux-lts-vivid_3.19.0-30.34~14.04.1.diff.gz";
"linux-lts-vivid_3.19.0-30.34~14.04.1.diff.gz": a tarball, with any changes made to upstream source, plus all the files created for the Debian package;
"linux-lts-vivid_3.19.0-30.34~14.04.1.dsc": a descrition file ".dsc" ending. It contains the name of the package, both, in its filename as well as content (after the Source: keyword);
"linux-lts-vivid_3.19.0.orig.tar.gz": the upstream tarball with ".tar.gz" ending (mind that in my experience it's not always a ".tar.gz" file, it can be in slightly different formats, such as ".tar.xz");
When you run apt-get source linux-image-$(uname -r), the upstream tarball is automatically patched with the modifications listed in "linux-lts-vivid_3.19.0-30.34~14.04.1.diff.gz" in "linux-lts-vivid-3.19.0":
Best Answer
The kernel source code installed by the linux-source
package is installed in the form of a compressed archive in the
/usr/src
directory. For example, if you are running Ubuntu 14.04 LTS, the kernel source archive will be at/usr/src/linux-source-3.13.0.tar.bz2
. You can unpack the source code in your current directory wherever you like to view it withIf instead you would like to know how to get and prepare the kernel source for building your own custom kernel, see the Ubuntu help document on compiling your own kernel or these other questions and answers: