Upgrading Debian Kernel From Source

Recently, I decided to dive deeper into Linux Kernel. So, I subscribed to some email lists and want to create a VM dedicated for running latest kernel. My first choice is Ubuntu, but it appears that Ubuntu (or Debian I think) has an annotation file limiting you to choose values of flags. Then I installed a Debian and make it running with a Linux 6.0.0-rc4+ kernel.

The step was quite straight and simple, we just need to:

  • Clone the Kernel source code
  • Copy the config of the current kernel
  • Make some changes in menu config
  • Compile and install

There are some essential commands I ran:

1
2
3
4
5
6
7
8
sudo apt install build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison fakeroot
sudo apt-get build-dep linux
mkdir -p ~/git/kernels; cd git/kernels
git clone -b staging-testing git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
cd staging
sudo cp /boot/config-5.10.0-18-amd64 .config
make menuconfig
make deb-pkg -j8

If you meet some errors like a subprocess returned an exit status. And the detailed error message is:

1
make[4]: *** No rule to make target 'debian/certs/debian-uefi-certs.pem', needed by 'certs/x509_certificate_list'.  Stop.

You can get the file from Debian’s GitLab: debian-uefi-certs.pem, and put it to the right location. You may also want to enable some debug flags to make kernel development easier.

Kernel Hacking

Most debug flags are located at Kernel Hacking menu, whiling some flags like driver debug is at Device Drivers menu.

Build output

If build succeed, you can find these file and install them by apt or dpkg.

It highly recommended that backup your machine before booting into the new kernel.

After a reboot, we are using the new kernel!

New kernel