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. 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- version — abiname
This package contains metadata from the linux source package that is needed to prepare and build the other source packages.
linux-headers- version — abiname -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- version — abiname -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.
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- version — abiname -common[- featureset ] package, and sets up symbolic links into its directory tree in such a way that the directory /usr/src/linux-headers- version — abiname [- 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.4, “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- version — abiname [- 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- version — abiname [- 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- version — abiname [- featureset ]- flavour
The kernel configuration file used to build this particular kernel. May be used to rebuild the kernel from source, if necessary.
/lib/modules/ version — abiname [- 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.
Building Kernel DEB packages
Recent kernel versions (as of 2013) no longer need tinkering to get usable headers.
Newer versions
# 1 $ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-$KVER.tar.xz # 2 $ cd /usr/src $ tar xvf linux-$KVER.tar.xz # 3: Patches, see below # 4.1 $ cd /usr/src/linux-$KVER $ cp /boot/config-`uname -r` .config $ make oldconfig # OR 4.2 $ cd /usr/src/linux-$KVER $ make xconfig # make config for textual interface, make menuconfig for curses interface # 5: The configuration option CONFIG_LOCALVERSION defines a string attached to the kernel version, e.g. "-1" $ sed 's/CONFIG_LOCALVERSION=.*$/CONFIG_LOCALVERSION="-1"/' .config # 6 $ make deb-pkg
linux-image-$KVER$REV_$KVER$REV$REV_$ARCH.deb # Kernel and modules linux-headers-$KVER$REV_$KVER$REV$REV_$ARCH.deb # Headers necessary to build external modules linux-firmware-image_$KVER$REV$REV_$ARCH.deb # Firmware files from the kernel sources as of version $KVER linux-libc-dev_$KVER$REV$REV_$ARCH.deb # Kernel-related headers
Older versions
NOTE These instructions are copied from the old guide I used to have here.
With semi-modern kernels it’s very simple. Here the version will include the pathlevel (2.6.x.y instead of 2.6.x), and AFAIK you can change the package revision but not install different builds of the same 2.6.x.y version in parallel.
I’m not yet too used to this method so I might be missing something. I don’t yet know if there’s a standard way to create a headers deb.
$ wget http://kernel.org/pub/linux/kernel/v2.6/linux-$KVER.tar.bz2 $ tar jxvf linux-$KVER.tar.bz2 && cd linux-$KVER (patches) (make config) $ fakeroot make KDEB_PKGVERSION=$KVER+$REV deb-pkg (KDEB_PKGVERSION *must* start with a number)
Example:
With KVER=2.6.32.41 and REV=toi-1 this will produce packages linux-image-2.6.32.41_2.6.32.41+toi-1_amd64.deb and linux-firmware-image_2.6.32.41+toi-1_all.deb .
Where kernel package name is linux-image-2.6.32.41 and version 2.6.32.41+toi-1 .
Kernel version ( $ uname -r ) will be 2.6.32.41, modules will go into /lib/modules/2.6.32.41 .
Headers
NOTE This notes have not much hand-holding, don’t mess with this unless you know what you’re doing.
Debian’s linux-headers packages (used to build out-of-tree modules) won’t be created from an older pristine kernel.
To have a viable homebrewed tree to build modules, clean the tree and remove unneeded files:
(Replace $YOURARCH with your architecture, x86_64 users should use x86)
$ cd /usr/src/. /linux-source-$KVER $ make clean prepare # prepare is required for building out-of-tree modules $ mkdir /usr/src/linux-headers-$KVER+$REV $ tar -c --exclude '*.c' --exclude '*.o' --exclude '*.ko' arch/$YOURARCH include scripts Makefile .config Module.symvers | ( cd /usr/src/linux-headers-$KVER+$REV ; tar xv )
Note this self-baked tree contains much more cruft than a proper linux-headers package, but I’m unsure on what to remove.
You’ll have to fix the /lib/modules/$KVER/build link unless you build the package in the correct path (/usr/src/linux-headers-$KVER+$REV).
From Debian-packaged sources
Important The package will contain a couple symlinks to the build location (its real path), so use an appropriate directory name under /usr/src . Using headers will allow a linux-headers package to fill in the links.
# 1 # apt-get install linux-source-$KVER build-essential kernel-package fakeroot # 2 $ cd /usr/src $ mkdir linux-headers-$KVER-$REV $ tar -jxv --strip-components=1 -C linux-headers-$KVER-$REV -f linux-source-$KVER.tar.bz2 # 3: Patches, see below # 4.1 $ cd /usr/src/linux-$KVER $ cp /boot/config-`uname -r` .config $ make oldconfig # OR 4.2 $ cd /usr/src/linux-$KVER $ make xconfig # make config for textual interface, make menuconfig for curses interface # 5 $ make-kpkg --rootcmd fakeroot --revision $EPOCH:$KVER~$X --append-to-version -$X-$ARCH --arch_in_name --initrd -j $NCPUS kernel_image kernel_headers
$ make-kpkg --rootcmd fakeroot --revision 2:2.6.32~3+toi --append-to-version -3-amd64+toi --arch_in_name --initrd -j 2 kernel_image kernel_headers
linux-image-2.6.32-3-amd64+toi_2.6.32~3+toi_amd64.deb # Kernel and modules linux-headers-2.6.32-3-amd64+toi_2.6.32~3+toi_amd64.deb # Kernel headers to build modules
Using an epoch ensures no Debian package will overwrite the customised version.
Package linux-image-* will contain a couple links to the build location, if the corresponding linux-headers-* isn’t installed these links will be removed. You can recreate the links by installing linux-headers-$KVER-$REV and re-installing linux-image-$KVER-$REV .
After installing the customised linux-image package you might need to manually create an initrd if it wasn’t done automatically.
# update-initramfs -k $VER-$REV -c # update-grub # Run ALWAYS after calling update-initramfs
Notes
Huge package/modules
Beware when importing configuration from a Debian kernel, if debugging symbols are enabled ( CONFIG_DEBUG_KERNEL option), the resulting package will be huge.
Quick way to re-configure it:
$ sed -i '/CONFIG_DEBUG_KERNEL/d' .config
Patches
TuxOnIce
Download TOI patch for the appropriate kernel version from http://www.tuxonice.net/. If not available, a close enough version MIGHT work.
# 1 $ cd /usr/src && wget http://www.tuxonice.net/downloads/all/tuxonice-$TUXONICEVER-for-$KVER.patch.bz2 # 2 $ cd linux-$KVER $ bzcat ../tuxonice-$TUXONICEVER-for-$KVER.patch.bz2 | patch -p1
Installing tuxonice-userui package is a good idea.
Debian-packaged
Some patches are available as debian packages, e.g. linux-patch-debianlogo .
The patch files can be found at /usr/src/kernel-patches/diffs/$PATCHNAME/$PATCH-$CLOSESTVERSION.gz .
1) Where $KVER is the kernel version, $ARCH is the host architecture codename and $REV is the revision