Build Linux kernel in Debian Bullseye

Follow the following steps to build Linux kernel

1. Install required packages.

sudo apt update
sudo apt install build-essential libncurses5-dev fakeroot xz-utils libelf-dev dwarves flex bison deb-helper libssl-dev

2. Download the kernel from kernel.org and extract it.

wget cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.16.tar.xz
tar -xvf linux-5.16.tar.xz

3. Go to the extracted folder and run copy the configuration file

cd linux-5.16
cp /boot/config*`uname -r` .config

4. Find CONFIG_SYSTEM_TRUSTED_KEYS and comment it out in .config file and save it.

#CONFIG_SYSTEM_TRUSTED_KEYS="debian/certs/debian-uefi-certs.pem"

5. Reconfigure the kernel save the changes.

sudo make menuconfig

6. Build the kernel. Simply press enter when you are uncertain.

sudo make clean
sudo make -j 4 bindeb-pkg LOCALVERSION=-pd KDEB_PKGVERSION=$(make kernelversion)-1

7. You will see some Debian (.deb) packages one folder above your compilation folder. Install it with the following commands:

sudo dpkg -i linux-image*.deb
sudo dpkg -i linux-headers*.deb

8. Now reboot and select the new kernel.

sudo reboot

9. You can check the kernel version by the following command:

uname -a