debian stretch kernel compile

debian kernels contain everything needed by everyone. customising your kernel is easy and highly recommended. i recommend using the same kernel version/source, to comply with debian security/updates.

http://debian.org/doc/manuals/debian-faq/ch-kernel.html
http://debian.org/releases/stable/i386/ch08s06.html
http://debian-handbook.info/browse/stable/sect.kernel-compilation.html
The kernels provided by Debian include the largest possible number of features, as well as the maximum of drivers, in order to cover the broadest spectrum of existing hardware configurations. This is why some users prefer to recompile the kernel in order to only include what they specifically need. There are two reasons for this choice. First, it may be to optimize memory consumption, since the kernel code, even if it is never used, occupies memory for nothing (and never “goes down” on the swap space, since it is actual RAM that it uses), which can decrease overall system performance. A locally compiled kernel can also limit the risk of security problems since only a fraction of the kernel code is compiled and run.

prerequisites

# apt-get install linux-source
current kernel source

# apt-get install build-essential
required to build debian packages

# apt-get install fakeroot
root not required, not recommended, to build packages.

tools
# apt-get install libncurses5-dev
for menuconfig

environment
$ mkdir ~/kernel
$ cd ~/kernel
$ tar -xaf /usr/src/linux-source-{version}
$ ln -s linux-source-{version} linux
$ cd linux
$ cp /boot/config-{version} .config
$ make oldconfig

build
$ make menuconfig
$ make clean
$ nice -n19 make -j3 deb-pkg LOCALVERSION=-nixventure

if you get such warnings
warning: File::FcntlLock not available; using flock which is not NFS-safe
ignore them, or
# apt-get install libfile-fcntllock-perl

install
a successful build creates many files in the parent directory. the most interesting one is the kernel (linux-image-*.deb), and perhaps the headers (linux-headers-*.deb), which we can install just like any deb pkg.

$ sudo dpkg -i ../linux-image-{version}.deb

dpkg will trigger an update of your bootloader. reboot and test your own customised brand new shiny kernel.

patch
$ apt-cache search linux-patch
$ apt-cache search kernel-patch
# apt-get install {linux/kernel}-patch-{??}
$ cd ~/kernel/linux
$ make clean
$ zcat /usr/src/kernel-patches/diffs/*/*.patch.gz | patch -p1

No comments:

Post a Comment

most viewed