Build the kernel
Compiling a kernel
Get straight to business and build your own Ubuntu-esque kernel
To compile your own kernel using Ubuntu (or any distro that uses Ubuntu kernels, for example Mint, elementary OS, but not Pop!_
OS) the first step is to get hold of the kernel sources. The official channel for vanilla kernel sources is https://kernel.org, but this isn’t necessarily the best place to start. Instead, we’ll use an Ubuntu kernel, which includes numerous patches and backported features. It also has the advantage of coming with a configuration very close to what you’re currently running (in fact it’s identical if you have the same version). So if we make only small changes there, then we’d hope the resulting kernel still has all the functionality of the old.
Besides the kernel source files, we also need the required build tools. If you’ve ever compiled anything before you’ll probably have all these. But if not, get them with the following: $ sudo apt build-dep linux linux-image-$(uname -r)
Using uname like this ensures the build tools you’re about to download correspond to the kernel you’re running, and that both are new. If you updated your system before this command, you might want to reboot (in case a new kernel was available) and then fetch the build tools (and kernel sources). If the command complains about not being able to find source packages, you may need to uncomment the lines beginning deb-src in /etc/apt/sources.list for both the main and updates repositories. Alternatively, since we’ve got a bit of a Perl flavour going on this issue, this little snippet will do it for you: $ sudo perl -i.bak -pe “s/^# (deb-src .* $(lsb_release -cs) (-updates)? main restricted$)/\$1/” /etc/apt/sources. list