Build your own kernel under Ubuntu using mainline (latest) kernel

Here we will show how to build your own kernel under Ubuntu 16/17/18. We are going to use

mainline kernel

because most of the cases when we need to build our own is when we need some new feature presented in the new kernels. So Ubuntu mainline kernels are selected new kernels, which are packed in deb packets for simplicity and can be used to test new features, but they are not supported by Ubuntu teams and you should test them really carefully if you want to use them in production!
The mainline kernels are here: This is the main address, where you could download the latest kernels and some other legacy one if you have old system.
This howto is based on and – we summarize the commands needed to build your new and latest kernel and show you some typical mistakes and problems during the process.
To show you more information our purpose will be to build the one of the latest kernels with low latency features enabled (Ubuntu has such type of kernel configuration)! And here is one of the most important dependency, which is not explicitly included or even mentioned in most of the tutorials for building your own kernels –

you MUST include new or even latest Linux firmware package

All Linux distros have a package or packages containing files with different firmware for multiple devices supported by the kernel modules. Basically firmware is used by a kernel module and it can be a micro code (program), which is uploaded in the device or just complete the kernel module to function properly with a device. Recent days firmware is like a black box the manufacturer of the devices pack a proprietary code in a firmware blob and the source code is unknown to the community.

The first thing you should do is to choose the kernel version you want to build. We want version 4.17.x as more stable of the latest 4.18, which was released a few days weeks ago (let’s wait for a month after the initial release before using it!).
So the main address is here and the kernel files, which we are going to use to rebuild are here
Keep on reading!