Build your own linux kernel

If there are problems with your hardware, like previously working hardware suddenly stops working after a kernel upgrade, then it is necessary to figure out, what’s the problem. One step towards this is, to build your own linux kernel.

As I’m using Debian, there is a howto available: Build a Debian Kernel Package.

Here’s the short version:

  1. Install needed packages to build the kernel:

    sudo apt-get install build-essential linux-source bc kmod cpio flex cpio libncurses5-dev libelf-dev

  2. Clone the kernel with git. That way, you might be able to bisect. There are two repos: bleeding edge from torvalds, which contains the latest release candidates: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

    And the stable line, which contains the bugfixed versions, which might not be available for your distro: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

    cd ~/temp
    git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    cd linux
    git remote add stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
    git fetch stable
    
  3. Then select the version, you want to build by checking out the tag, e.g. git checkout v5.7.10

  4. Reuse your distro’s config and configure the kernel:

    cp /boot/config-5.7.0-1-amd64 .config
    make oldconfig
    

    You’ll need to answer some questions. Some features are new and were not available in your distro yet.

  5. Remove the trusted keys that would be used to sign the kernel. Debian has its own keys, which you do not have…

    make menuconfig: -> Cryptographic API -> at the bottom “Certificates for signature checking” -> Additional X.509 keys for default system keyring. Just remove the value.

  6. Now build:

    make -j`nproc` bindeb-pkg
    

After a long time, you’ll have some packages in the parent folder. Install some of them with dpkg:

dpkg -i linux-headers-5.7.10_5.7.10-1_amd64.deb linux-image-5.7.10_5.7.10-1_amd64.deb

And then reboot and test.

Note: You’ll need to have quite some disk space free. After building, the linux folder is 25g big. You can clean up after you’ve finished with make clean. This will free about 20g.

For me, I was lucky, the problem was fixed already in the newer kernel version. So, I only built one kernel. My problem was, that the USB Audio from my Dell D3100 USB3.0 Dock didn’t work anymore - it was very slow and slowing down the video playing as well. Maybe it is similar to this problem https://bugzilla.kernel.org/show_bug.cgi?id=207065, but the patch described there, was already in my distros kernel. It would have been a shame to dispose this “docking” station, since the only functionality left would have been a USB hub. I don’t use the DisplayLink technology included there, because it’s not properly supported and part of it is proprietary. Hence, suspend to ram didn’t work reliably. It also used many CPU cycles for displaying.

Andreas Dangel | subscribe via RSS | adangel | .onion © Copyright 2020. adangel.org (25 July 2020)