Custom KernelΒΆ

These are instructions for building a custom Linux Kernel as a Debian package on the system where it will be installed.

  • The kernel will be built using the current Kernel configuration with minimal custom changes, you can add more.

  • The kernel will be built as an installable Debian Package, this is conventient as it can easily be uninstalled again.

  • The kernel is built from sources available in the folder $HOME/git/linux.

Install pre-reqs:

#!/usr/bin/env bash
sudo apt-get install \
  bc \
  build-essential \
  cpio \
  flex \
  kmod \
  libelf-dev \
  libncurses5-dev \
  libssl-dev \
  linux-source \
  rsync \
  time

Grab the kernel sources and then do:

make olddefconfig

Disabled trusted keys and debug-info:

./scripts/config --disable CONFIG_DEBUG_INFO
./scripts/config --disable SYSTEM_TRUSTED_KEYS
./scripts/config --disable SYSTEM_REVOCATION_KEYS

Define the environment variable LOCALVERSION, this will embed the string in the kernel-version, making it easy to identify your customized Kernel:

export LOCALVERSION="foo42"

Then go ahead and build:

/usr/bin/time make -j`nproc` bindeb-pkg

The Debian packages are emitted in the parent directory, this can get messy. So, go ahead and put the packages somewhere else, e.g.:

rm -r "${HOME}/packages/${LOCALVERSION}"
mkdir -p "${HOME}/packages/${LOCALVERSION}"
mv ../{*.deb,*.buildinfo,*.changes} "$HOME/packages/${LOCALVERSION}"

Go ahead and install it by invoking:

sudo dpkg -i "$HOME/packages/${LOCALVERSION}/*.deb"

You organize the packages as you see fit, but something like the above is not a bad idea.