I am following this to learn to compile the kernel. I used
apt-get source linux-image-$(uname -r)
to download the source code of the Linux kernel I am curretly using.
After running the above command, the following files (and directories) were downloaded.
user $ ls -l
total 130972
drwxrwxr-x 27 sps sps 4096 Oct 16 03:10 linux-lts-vivid-3.19.0
-rw-rw-r-- 1 sps sps 10980684 Oct 5 10:54 linux-lts-vivid_3.19.0-30.34~14.04.1.diff.gz
-rw-rw-r-- 1 sps sps 7396 Oct 5 10:54 linux-lts-vivid_3.19.0-30.34~14.04.1.dsc
-rw-rw-r-- 1 sps sps 123115155 May 6 21:35 linux-lts-vivid_3.19.0.orig.tar.gz
user $
In the same page it is mentioned:
Building the kernel is quite easy. Change your working directory to the root of the kernel source tree and then type the following commands:
But I am not sure which is the "root of the kernel source tree".
Is it the current directory (where I ran apt-get source ...
and where I have the above listed files)?
Or, is it the directory:
drwxrwxr-x 27 sps sps 4096 Oct 16 03:10 linux-lts-vivid-3.19.0
or, should I extract the tarball
-rw-rw-r-- 1 sps sps 123115155 May 6 21:35 linux-lts-vivid_3.19.0.orig.tar.gz
Output for uname -r
:
user $ uname -r
3.19.0-30-generic
user $
From the Debian Wiki:
It's quite the same for Ubuntu, and in your case:
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":The root of your kernel tree is the directory
linux-lts-vivid-3.19.0
.About the other files:
In the tarball
linux-lts-vivid_3.19.0.orig.tar.gz
you can find the "vanilla" kernel, as released upstream; to this kernel the Ubuntu developers have added patches, drivers, changed things that are collected in thediff
which is compressed inlinux-lts-vivid_3.19.0-30.34~14.04.1.diff.gz
.Hmmm. When you run the command
the command should automatically extract the source tarballs and patch them to create a directory called after your kernel. In your case, it looks like it is called 'linux-lts-vivid-3.19.0' - it is there in your directory listing.
So, that is the source directory, you should run:
and then continue to follow the instructions