Linux debian kernel source

How to install full kernel source on Debian or Ubuntu

Question: I need to download and install a full kernel source tree to compile a custom kernel for my Debian or Ubuntu system. What is a proper way to download full kernel source on Debian or Ubuntu?

Before installing full kernel source on your Linux system, ask yourself whether you really need the full kernel source. If you are trying to compile a kernel module or a custom driver for your kernel, you do not need the full kernel source. You only need to install matching kernel header files, and that’s it.

You need the full kernel source tree only if you want to build a custom kernel after modifying the kernel code in any way and/or tweaking default kernel options.

Here is how to download and install full kernel source tree from Debian or Ubuntu repositories. While you can download the official kernel source code from https://www.kernel.org/pub/linux/kernel/, using distro’s repositories allows you to download a kernel source with the maintainer’s patches applied to it.

Install Full Kernel Source on Debian

Before downloading kernel source, install dpkg-dev , which contains a suite of development tools needed to build Debian source packages. Among other things, dpkg-dev contains dpgk-source tool which can extract a Debian source package and automatically apply patches.

$ sudo apt-get install dpkg-dev

Next, run the following command to download full kernel source.

$ apt-get source linux-image-$(uname -r)

Along with the full kernel source ( linux_X.X.XX.orig.tar.xz ), any available kernel patches ( linux_X.X.X+XXX.debian.tar.xz ) and source control file ( linux_XXXX.dsc ) will also be downloaded and stored in the current directory. The .dsc file instructs how the patches are applied to the kernel sources.

Upon the completion of download, the above command will automatically invoke dpkg-source tool, which will unpack the downloaded kernel source in the current directory, and apply downloaded patches according to .dsc file.

The final full kernel source tree will be available in the current directory as linux-X.X.XX .

Install Full Kernel Source on Ubuntu

If you want to install full kernel source, the Debian way described above should work on Ubuntu as well.

There is another way to download full kernel source on Ubuntu. You can actually check out the kernel source tree maintained by Canonical for different Ubuntu releases.

$ 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 check out code from » ubuntu-trusty » Git repository.

Once you check out the Git repository, use the following command to install necessary development packages to meet the build dependencies for the kernel source tree.

$ sudo apt-get build-dep linux-image-$(uname -r)

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Читайте также:  Create and write to file linux

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Источник

Chapter 3. Debian kernel packages

The linux source package supports building of kernel images and headers for all currently supported architectures. The linux-latest source package supports building of meta-packages that depend on them. The linux-signed source package supports building of signed kernel images and modules for some architectures. Subsequent sections of this chapter document the naming and contents of the binary packages built from these source packages.

3.2. Architecture-independent packages

This package contains the Debian kernel source tarball. The patchlevel of the source is determined by the Debian revision of the package, for example the version 4.2.5-1 of the package linux-source-4.2 contains the version 4.2.5 of the Debian kernel source patched to patchlevel 1. Once the package is installed, the source tarball is available at /usr/src/linux-source- version .tar.xz .

This package contains the manual pages for the functions, constituting the kernel API. These pages are installed into /usr/share/man/man9/ , and are accessible with the standard man command. Due to filename conflicts, only one linux-manual package may be installed at any given time.

This package contains the rest of the kernel documentation in various formats. It is installed in /usr/share/doc/linux-doc- version .

linux-support- versionabiname

This package contains metadata from the linux source package that is needed to prepare and build the other source packages.

linux-headers- versionabiname -common[- featureset ]

This package contains a common set of kernel headers for a particular featureset (or no featureset). Together with the flavour-specific linux-headers package it provides a full set of kernel headers, suitable for building of out-of-tree modules. This package should not normally be installed directly, but only as a dependency of the flavour-specific headers package (see below). It unpacks into the /usr/src/linux-headers- versionabiname -common[- featureset ] directory. Before version 4.9 these packages were architecture-dependent.

3.3. Architecture-dependent packages

The kind of hardware the particular kernel package is designed for is uniquely identified by the architecture , featureset , and flavour . Kernels for all architectures are built from the same Debian kernel source tree, which is obtained using the procedure described in Chapter 2, Debian kernel source. Each architecture usually has multiple flavours of the binary kernel images. Different flavours correspond to different kernel configuration files, used to build the binary images from the same kernel tree.

Читайте также:  Linux mint silvia win7

In order to build a working kernel with an extra featureset not provided by the upstream source, additional changes to the Debian kernel source are required. Again, multiple flavours of binary images may be built from the featureset tree. For example, the i386 architecture has a number of different flavours, such as 686 and 686-pae , built from the common Debian kernel source. It also contains the rt featureset. The source tree for building the kernels for each of these featuresets is obtained by applying additional patches to the Debian kernel source. It may be used to build the rt-686-pae binary image flavours. The names of the Debian binary packages incorporate the name of the flavour and, if necessary, the name of the featureset (there is no need to worry about the name of the architecture, since Debian tools will only allow installation of the packages with «correct» architecture). If the arch does not have any featuresets, the featureset part is omitted from the name, as indicated by the square brackets below.

Package names also include the abiname , a small integer, which identifies the kernel’s binary compatibility level. The kernels with different abinames are binary incompatible, so upgrading to a kernel with a different abiname will most likely require recompilation of third-party binary modules against the new kernel. The list of architecture-dependent packages together with a short description is given below.

This package provides flavour-specific header files. It depends on the corresponding linux-headers- versionabiname -common[- featureset ] package, and sets up symbolic links into its directory tree in such a way that the directory /usr/src/linux-headers- versionabiname [- featureset ]- flavour appears to contain a full set of headers, required for building of out-of-tree kernel modules. For more information on this check out Section 4.7, “Building out-of-tree kernel modules”. A complete set of kernel headers matching the currently running official kernel may be installed with a command

apt-get install linux-headers-$(uname -r)

These meta-packages provide (via dependencies) the latest binary image and matching set of header files (respectively) for a particular flavour. Example: linux-image-rt-686-pae

linux-image- versionabiname [- featureset ]- flavour

This package contains the binary kernel image and pre-built binary modules for a particular arch/featureset/flavour combination. Names of the files installed by this package are architecture-dependent. Typical locations of essential files for the i386 architecture are:

The binary (compressed) kernel image.

/boot/initrd.img- versionabiname [- featureset ]- flavour

Initial RAM filesystem (initramfs) image. Note, that this file is automatically generated in the installation process and is not shipped as a part of the package. See Chapter 7, Managing the initial ramfs (initramfs) archive for more details.

/boot/config- versionabiname [- featureset ]- flavour

The kernel configuration file used to build this particular kernel. May be used to rebuild the kernel from source, if necessary.

Читайте также:  Выбрать версию java linux

/lib/modules/ versionabiname [- featureset ]- flavour /

Directory containing the pre-built binary kernel modules.

This package contains the binary kernel image and pre-built binary modules for a particular arch/featureset/flavour combination, that are meant to be signed and copied into a package without the -unsigned suffix. There is normally no need to install these packages.

This package provides Linux kernel headers for use by userspace programs, such as GNU glibc and other system libraries.

Источник

Chapter 2. Debian kernel source

The kernels in Debian are distributed in binary form, built from the Debian kernel source. It is important to recognize that Debian kernel source may be (and in most cases is) different from the upstream (or «pristine») kernel source, distributed from www.kernel.org and its mirrors. Due to licensing restrictions, unclear license information, or failure to comply with the Debian Free Software Guidelines (DFSG), parts of the kernel are removed in order to distribute the source in the main section of the Debian archive. Such removal produces linux_ version .orig.tar.xz tarball, which serves as the original upstream source. version is the actual upstream version.

The guidelines for firmware removal were set by the Handling source-less firmware in the Linux kernel General Resolution and the position statement by the release managers. As of version 2.6.31-1, all known sourceless firmware has been removed from the Debian package, but much of it is included in the firmware-nonfree package. Additional information about firmware licensing and removals may be found at the Debian Wiki page KernelFirmwareLicensing.

2.2. Debian kernel patches

The source from which the Debian binary kernels are built is obtained by taking the source from linux_ version .orig.tar.xz (that is, pristine kernel source with problematic parts removed) and applying a set of Debian patches. These patches typically implement essential fixes for serious bugs and security holes. The Debian version of the kernel packages has the form versionrevision where version is the upstream version of the kernel (like 3.2.20) and revision determines the patchlevel. For example, the packages with version 3.2.20-1 are built from the linux_3.2.20.orig.tar.xz source, patched up to patchlevel 1. Certain packages include extra ‘featuresets’ not included in the upstream source, such as rt .

2.3. Policy for patch acceptance

The general policy of the Debian kernel team is that a patch must either fix a bug or add hardware support, and must be based on a change already accepted by the upstream kernel maintainers. The change does not need to have been included in an upstream release yet. This policy allows the team to drop most patches when moving to a new upstream version, rather than having to maintain an increasing series of Debian-specific patches. The recommended procedure for inclusion of patches introducing optional features is to submit to the upstream maintainer.

Источник

Оцените статью
Adblock
detector