I need to download and install the full tree kernel source code for my Debian or Ubuntu for compiling a customized kernel. So what are the feasible methods to download the complete kernel source code on Debian or Ubuntu?
Before installing the complete kernel source code for your Linux system, you must first ask if you really need to do so. If you just try to compile a kernel module or customize the driver for the kernel, you do not need the complete kernel source code tree. You only need to install some header files corresponding to the kernel. This is enough.
You need a complete kernel source code tree only when you need to generate a customized kernel and some default kernel settings in the kernel source code need to be adjusted.
Here we will explain how to download and install the full tree kernel source code in the Debian or Ubuntu Library. You can.
Install the complete kernel source code on Debian
Before downloading the kernel source code, install dpkg-dev, which contains the development tool suite you need to generate the source code on Debian. In addition, dpkg-dev is also included in the dpgk-source tool used to decompress the Debian source code package and automatically patch it.
$ Sudo apt-get install dpkg-dev
Then, run the following command to download the complete kernel source code.
$ Apt-get source linux-image-$ (uname-r)
_Xxxx.dsc. These files will be downloaded and stored in the current directory. The. dsc file shows how to patch the kernel source code.
After the download is complete, the above Command will automatically call the tool dpkg-source to decompress the downloaded kernel source code to the current directory, and patch it according to the. dsc file.
The final complete kernel source tree will be displayed in the current directory in the form of a "linux-X.X.XX.
Install the complete kernel source code on Ubuntu
If you want to install the complete kernel source code, the above practices on Debian still work on Ubuntu.
There is another way to install the complete kernel source code on Ubuntu. In fact, you can check the kernel source code tree maintained by Canonical for different Ubuntu distributions.
$ Sudo apt-get install git
$ Git clone git: // kernel.ubuntu.com/ubuntu/ubuntu-$ (lsb_release -- codename | cut-f2). git
For example, if you are using Ubuntu 14.04, the above Command will view the code in the Git "ubuntu-trusty" repository.
Once your query of the Git repository is complete, run the following command to install an important development kit to access the dependencies required to generate the kernel source code tree.
$ Sudo apt-get build-dep linux-image-$ (uname-r)