Score:0

18.04.5 kernel build fails

us flag

Good day all!

Not sure where to begin.

Compiling 5.4.125 source from kernel.org and I get this

  CC [M]  kernel/kheaders.o
debian/rules:6: recipe for target 'build' failed
make[2]: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
scripts/Makefile.package:73: recipe for target 'deb-pkg' failed
make[1]: *** [deb-pkg] Error 2
Makefile:1469: recipe fpr target 'deb-pkg' failed
make: *** [deb-pkg] Error 2 

here are the commands I used (note two diff sources where the later fails):

sudo apt build-dep linux linux-image-$(uname -r)
sudo apt install libncurses-dev fakeroot

# the current kernel version works ok ...
apt source linux-image-unsigned-$(uname -r)

# the latest 5.4.123 has the issue ...
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.123.tar.gz
tar -xf linux-5.4.123.tar.gz

make oldconfig

# just to check settings ... no changes.
make menuconfig

make -j`nproc` deb-pkg
Score:0
es flag

In the absence of any useful information (what commands did you invoke? What steps did you do before?) one can only guess that you followed those instructions:

https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

Which of course only works to build a kernel from a Debian source package or from the Ubuntu git repository.

If you got your sources from kernel.org, as you wrote, they will probably not come with the Debian packaging part, so you need to follow the standard instructions for building a kernel, e.g. here:

https://www.linux.com/topic/desktop/how-compile-linux-kernel-0/

But that means installing an unpackaged kernel directly to your system, and the package manager (dpkg, apt) knows nothing about it and might happily overwrite it or remove it with one of the next regular updates, and your hand-crafted custom kernel might be gone.

So you could prevent this with some tactical apt-mark hold command, but then you'd never get any security update again; or you could do it the regular Ubuntu way and get the sources from kernel.ubuntu.org and build a .deb package for that kernel and install it.


Notice that trying to use a 5.x kernel on an Ubuntu 18.04 that comes with a 4.x kernel (4.5.0-144 right now) might explode in your face when all kinds of other low-level packages are not compatible to that much newer kernel. This might or might not work. If it doesn't, you probably don't want to rebuild a good part of the distribution which might turn out to be necessary.


Edit: If your priorities are that you need that latest 5.4 kernel, go for a more recent Ubuntu release; if you need an LTS release, 20.04 LTS is a much better starting point, and 21.04 (albeit not an LTS release) is better still.

Every once in a while low-level system packages need to be adapted to work well with a newer kernel; UDEV comes to mind, to name just one. If you use a newer kernel, but still the older UDEV (or other similar low-level subsystems), some system events may be sent in slightly different situations as before, and some tools may break in subtle ways. It doesn't need to be like that, but the possibility exists.

There is a reason why the distribution is released as a whole in certain intervals; the most important thing that a Linux distributor does is to integrate all the different subsystems to work well together. A Linux distribution is not just a bunch of pieces to be thrown together at random, and everything will work out fine; there is a lot of expertise and work involved.

You can increase your chances of things working well if the age of components is roughly the same; but a recent kernel from mid-2021 and all the rest from early 2018 (i.e. over 3 years earlier!) is asking for trouble.

You might get lucky, of course, but this might be pushing your luck.

keith bradley avatar
us flag
... I edited to add recipe I used slightly modified from the article you linked ... Your details answered my question ... but I wonder how I can get past this ... I must use a kernel in 5.4 family that has a corresponding PREEMPT-RT patch version ... I could not match the patch to any ubuntu source ... am I deadlocked?
keith bradley avatar
us flag
In addition ... this is a test platform so I am not worried about taking risks ... I can forgo updates during testing.
keith bradley avatar
us flag
Also ... I am using 18.04.5 ... going from 5.4.0 to 5.4.123 didn't seem too much since when I get the ubuntu kernel source it updates all the way to 5.4.114 anyway.
HuHa avatar
es flag
Edited my answer. My 18.04.05 has kernel 4.15.0-144. If you have 5.4.0, that's not the normal one that comes with that distro.
keith bradley avatar
us flag
Thanks HuHa for all your expert help ... only thing I wanted to let you know is that I built my test machine several times and did apt update / upgrade and 5.4.0 is the kernel I ended up with before I did anything else ... Looks like it was a recent patch too ... on the kernel.ubuntu.com it's dated a few days ago ... I will go with your advise and test with 21.04 since the PREEMPT-RT patch would be better anyway ... thanks again.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.