9.2.4. Compiling and Building the Package
Clean Up Before
Rebuilding
If you have already compiled a kernel in the directory and wish to rebuild everything
from scratch (for example because you substantially changed the kernel configura-
tion), you will have to run
make clean
to remove the compiled files.
make distclean
removes even more generated files, including your
.config
file, so make sure to back
it up first.
Once the kernel configuration is ready, a simple
make deb-pkg
will generate up to five Debian
packages in standard
.deb
format:
linux-image-version, which contains the kernel image and the
associated modules;
linux-headers-version, which contains the header files required to build ex-
ternal modules;
linux-firmware-image-version, which contains the firmware files needed by some
drivers (this package might be missing when you build from the kernel sources provided by De-
bian or Kali);
linux-image-version
-dbg, which contains the debugging symbols for the kernel image
and its modules; and
linux-libc-dev, which contains headers relevant to some user-space libraries
like GNU’s C library (glibc).
The
version is defined by the concatenation of the upstream version (as defined by the variables
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION in the
Makefile
), of the LOCALVER-
SION configuration parameter, and of the LOCALVERSION environment variable. The package
version reuses the same version string with an appended revision that is regularly incremented
(and stored in
.version
), except if you override it with the KDEB_PKGVERSION environment
variable.
$
make deb-pkg LOCALVERSION=-custom KDEB_PKGVERSION=$(make kernelversion)-1
[...]
$
ls ../*.deb
../linux-headers-4.9.0-kali1-custom_4.9.2-1_amd64.deb
../linux-image-4.9.0-kali1-custom_4.9.2-1_amd64.deb
../linux-image-4.9.0-kali1-custom-dbg_4.9.2-1_amd64.deb
../linux-libc-dev_4.9.2-1_amd64.deb
To actually use the built kernel, the only step left is to install the required packages with
dpkg -i
file.deb
. The “linux-image” package is required; you only have to install the “linux-headers”
package if you have some external kernel modules to build, which is the case if you have some
“*-dkms” packages installed (check with
dpkg -l ”*-dkms” | grep ^ii
). The other packages
are generally not needed (unless you know why you need them)!