Compiling new Linux Kernel

Those are the commands I used to create custom kernel packages for Debian/Ubuntu based systems.

1. Install required packages

sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev

2. Extract source code and import config from current kernel

cd linux-5.x.x
cp -v /boot/config-$(uname -r) .config

make olddefconfig

3. Edit  .config file and set the following variables

CONFIG_SYSTEM_TRUSTED_KEYS = ""
CONFIG_DEBUG_INFO=n

Building without black SYSTEM_TRUSTED_KEYS will fail the build.
Building with debug info will take much more time and space

Compile code and generate deb package, add LOCALVERSION if you want to add a kernel suffix

make clean
make -j8 deb-pkg LOCALVERSION=-custom

 

Leave a Reply

Your email address will not be published. Required fields are marked *