2021/03/20

build Ubuntu 20 (focal) linux kernel by generic and lowlatency

PROGRAMMING   

Build the Linux Kernel for Ubuntu20.

I used this Blog as a reference. It really helped me a lot with its well-written points.

Also, I think the official Build explanation can be found here. This is also very helpful.

https://wiki.ubuntu.com/Kernel/Dev/KernelGitGuide

https://help.ubuntu.com/community/Kernel/Compile

generic

Check out the Ubuntu Kernel code, also known as Ubunt 20. That’s why it has folcal.git at the end.。

git clone git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git

Next, look up the tags for ubuntu 20, type git tag, and you will get a list of tags. Select the version you want to build.

cd ubuntu-focal
git tag 

Then change to the version you want to build.

git checkout Ubuntu-hwe-5.8-5.8.0-43.49_20.04.1

Make clean and build. First, build the generic

fakeroot debian/rules clean
AUTOBUILD=1 fakeroot debian/rules binary-generic

If you get an error, it is a good idea to check the tool system. See the page I referred to and install the missing tools with apt.

If the build is successful, a deb file will be generated.

ls ../
linux-tools-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
linux-cloud-tools-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
linux-modules-extra-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
linux-image-unsigned-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
linux-buildinfo-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
linux-modules-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
linux-headers-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb

Install the built Kernel.

cd ..
dpkg -i ./linux-modules-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
sudo dpkg ./linux-image-unsigned-5.8.0-45-generic_5.8.0-45.51~20.04.1_amd64.deb
sudo apt-get install linux-hwe-5.8-headers-5.8.0-43
sudo dpkg -i linux-headers-5.8.0-43-generic_5.8.0-43.49~20.04.1_amd64.deb
sudo dpkg -i linux-modules-extra-5.8.0-43-generic_5.8.0-43.49~20.04.1_amd64.deb 

After installation, at boot time, hit ESC or SHIFT to display the grub screen, and select the installed kernel to boot with the built kernel.

To check the version of the Kernel you are running, use the uname command.

uname -r
5.8.0.-generic

Lowlatency

The next step is to build the Lowlatency Kernel.

In the code that I checked out with git, there seems to be a file that contains the configuration for each flaver.

vi ubuntu-focal/debian.hwe-5.8/config

It seems that the Kernel settings for each flaver are written in this file. For example, CONFIG_PREEMPT is N for generic, but Y for lowlatency.

CONFIG_PREEMPT policy<{'amd64-generic': 'n', 'amd64-lowlatency': 'y', 

Try to build lowlatency, just run it in the directory you checked out in generic.

fakeroot debian/rules clean
AUTOBUILD=1 fakeroot debian/rules binary-lowlatency

When built, the file will be generated.

ls ../
linux-headers-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb
linux-image-unsigned-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb
linux-modules-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb
linux-buildinfo-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb
linux-cloud-tools-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb
linux-tools-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb

Next, install Lowlatecy. If you installed the same version of generic earlier, you don’t need to install the header, and there seems to be no module-extra.


sudo dpkg -i linux-modules-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb
sudo dpkg -i linux-image-unsigned-5.8.0-43-lowlatency_5.8.0-43.49~20.04.1_amd64.deb

I was wondering what lowlatency was, but it seems to be one of the Ubuntu features.

Prev:«

Next: »