Ubuntu18.04 kernel upgrade (use compilation method to reach kernel 6.1.62)

My computer is a thinkbook16+ I bought in 2022. I added an external graphics card to it during Double 11 this year. It can be successfully recognized and used on Windows, but it cannot be used on Ubuntu18.04 because the Thunderbolt interface cannot be recognized. Later, the version changed to 20.04 and it worked again. After comparing the differences between the two, I initially guessed that the kernel version was slightly lower, so I tried to upgrade the kernel and verified my guess.

Instructions before installation:

The kernel version that comes with ubuntu18.04 is 5.4.0. After verification from many parties and actual testing, it was found that the highest kernel version that can be downloaded from the official website (No error is reported during compilation) It’s 5.9, thanks to this good brother for the information. But unfortunately, after testing, the 5.9 Thunderbolt interface is not recognized and can only be looked at the 6.x kernel.

Ubuntu 18.04 system, graphics card, wireless, wired network card drivers are missing, reinstalling the system, upgrading the kernel, HDMI output, etc. Work records_ubuntu update network card driver_Analeptic’s blog-CSDN blog

However, kernels above 5.9 cannot compile and upgrade the kernel by downloading several .deb files on the Index of /mainline (an error will appear such as the libc6 version is low and does not match). Only Compiled methods can be used.

1. Check the current ubuntu kernel version

uname -r

ok, make sure our current Ubuntu kernel is 5.4.0, and then select the kernel version.

2. Select the kernel version

Go to The Linux Kernel Archives and select a kernel version.

2.1 has no requirements for the kernel version you want to upgrade

If you don’t want to listen, just click the yellow download button above and wait.

2.2 has requirements for the kernel version

If you see the tarball, click on it and wait.

Note: There are prefixes such as mainline, stable, and longterm in front of the relevant versions. I think it is better to choose stable because this version is relatively new and stable.

3. Dependency installation

 sudo apt-get install libncurses5-dev openssl libssl-dev
 sudo apt-get install build-essential openssl
 sudo apt-get install pkg-config
 sudo apt-get install libc6-dev
 sudo apt-get install bison
 sudo apt-get install flex
 sudo apt-get install libelf-dev
 sudo apt-get install zlibc minizip
 sudo apt-get install libidn11-dev libidn11

4. Unzip

Unzip the installation package you just downloaded. For example, I downloaded 6.1.62, so it is

 tar -xavf linux-6.1.62.tar.xz

5. Start installation

5.1 Move the decompressed files to /usr/src

sudo mv linux-6.1.62/ /usr/src/
cd /usr/src/linux-6.1.62/

5.2 Preparation before installation

Clean the source code directory, just in case

sudo make mrproper
sudo make clean

5.3 Configuring the kernel

sudo make menuconfig

(An error may occur, please see the solutions to related errors later)

The above window will appear, and you can configure it yourself if necessary. As novices, we don’t move anything, just select Exit and press Enter.

Start compilation and installation in 5.4

sudo make -j16

Start the long compilation, do other things during this time

Note: It is recommended to execute make several times so that you can see where errors are reported. I have also encountered some of them. The solutions will be found later

Sign of success: Kernel ready (#2)

Then execute

sudo make -j16 INSTALL_MOD_STRIP=1 modules_install
sudo make install

Here’s an explanation of why you added INSTALL_MOD_STRIP=1. If you don’t add it, the compilation can still be successful, and the compiled kernel options will also appear on grub. However, when you restart and select the newly compiled kernel version, out of memory may appear, making it impossible to enter the system.

6. Update grub

sudo update-grub

You can see that the kernel we compiled is already in grub, then restart and select your newly compiled kernel.

7. Results

uname -r

You can see that our kernel is now 6.1.62. Let’s look at the thunderbolt interface we need.

ok, that’s it too. Let’s start connecting to the external graphics card and have a great time!

Error report summary:

Error 1: Your display is too small to run Menuconfig! It must be at least 19 lines by 80 columns.

Solution:

Enlarge the window (terminal)

Error 2: No rule to make target canonical-revoked-certs.pem

Solution:

sudo scripts/config --disable SYSTEM_REVOCATION_KEYS

Error 3: BTF: .tmp_vmlinux.btf: pahole (pahole) is not available Failed to generate BTF for vmlinux Try to disable CONFIG_DEBUG_INFO_BTF

Solution:

sudo apt-get install dwarves

Error 4: /bin/sh: 1: lz4c: not found
arch/x86/boot/compressed/Makefile:144: recipe for target ‘arch/x86/boot/compressed/vmlinux.bin.lz4’ failed

Solution:

sudo apt-get update
sudo apt-get install liblz4-tool 

Error 5: After the kernel is compiled successfully, restart, select the new kernel, and out of memory appears

Solution:

 sudo make modules_install
Change to sudo make -j16 INSTALL_MOD_STRIP=1 modules_install

11.15 Update: Preparations before compiling and updating (very important!!!)

After that, I reinstalled the system again and followed the above steps to compile and update the kernel. Although the kernel was successfully upgraded (this time the kernel version was 6.6.1), the thunderbolt interface was still not recognized! ! !

Later, through my testing, I found that I need to use dpkg -i *.deb to upgrade the kernel to version 5.9 before compiling and installing (I chose 5.9.16)

1) Go to Index of /mainline and select the kernel version to be downloaded (I chose 5.9.16)

2) Use wget to download 4 .deb files

wget linux-headers-5.9.16-050916_5.9.16-050916.202012211331_all.deb
wget linux-headers-5.9.16-050916-generic_5.9.16-050916.202012211331_amd64.deb
wget linux-image-unsigned-5.9.16-050916-generic_5.9.16-050916.202012211331_amd64.deb
wget linux-modules-5.9.16-050916-generic_5.9.16-050916.202012211331_amd64.deb

3) Run

sudo dpkg -i *.deb

Then wait for completion and restart to check after completion.

After the kernel is updated to 5.9, then use the compilation method to update to 6.6 and find that the thunderbolt interface can be recognized.