1

I recently compiled and installed a Linux kernel on my Kubuntu computer. The way I did this was, I downloaded the source .tar.gz from kernel.org, extracted it and used the following commands (running in the top directory of the source package) to compile and install it:

make oldconfig
make -j4
sudo make modules_install
sudo make install

When I rebooted, however, I got a message saying "Error: out of memory" and when I pressed a key to continue it gave a kernel panic screen saying "not syncing: VFS: Unable to mount root fs on unknown-block(0,0)".

My other kernels work fine, so I can still boot up normally. But I'm curious to know why that kernel doesn't work and what I can do to get it working.

I tried this with a few versions (5.9.12, 5.9.14 and 5.10.2) and got the same result, so the exact version doesn't seem to be the issue here. But I know that I used to compile kernels like this all the time and they ran without issues. So I tried a bunch of stuff and eventually figured out that UEFI appears to be the culprit. This same kernel will work if I install it on a legacy system. Secure boot is disabled on the (UEFI) PC in question, so I figure it can't have to do with secure boot keys. It seems to be something about UEFI, but not secure boot, that breaks it.

However, upon searching the internet I couldn't find anything on getting a compiled Linux kernel to boot with UEFI. So is there really some additional thing I must do? Or is the problem something else?

Edit: I don't understand why my question was closed. But in case it requires more clarification, I am asking as follows: If I download the linux kernel source code from kernel.org or the code from which the Ubuntu kernels are built from here (https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.10.4/) and compile it using the commands above, I find that it will boot fine in BIOS but not UEFI. My question is why.

7
  • 1
    Did you also build the other kernels? You might want to take a look at this page: wiki.ubuntu.com/Kernel/BuildYourOwnKernel Commented Dec 28, 2020 at 3:08
  • Did you copy the configuration of the distribution kernel into the top directory of the source package (e.g. cp /boot/config-$(uname -r) <source-package-dir>/.config) to be used as a basis for make oldconfig? If you didn't, you got whatever configuration was the kernel developers' default - which might not have been appropriate for your system.
    – telcoM
    Commented Dec 31, 2020 at 17:40
  • @telcoM I tried both ways. But anyway I thought make oldconfig just does the same thing... stackoverflow.com/questions/4178526/… Commented Jan 1, 2021 at 5:29
  • @EduardoTrapani I tried building it the way they describe on that page and using the source from the Ubuntu repos (which includes a few additional folders) and it worked! But I'm wondering why it doesn't work with the code from kernel.org or if I use the source from which the Ubuntu kernels are built (kernel.ubuntu.com/~kernel-ppa/mainline/v5.10.4) Commented Jan 5, 2021 at 7:10
  • Kernel makeconfig became hard about with linux 3.x . It is because the drivers are now complexly built over each other, resulting that make oldconfig leaves often some essential driver out (to find and mount the root partition). You need to investigate and play with make menuconfig, and analyze the boot output. What it detects, what it does not.
    – peterh
    Commented Jan 5, 2021 at 10:35

1 Answer 1

0

sudo update-initramfs should solve the problem.

5
  • I think the "make install" script already ran that. But anyway I tried "sudo update-initramfs -c -k 5.10.2" and then "update-grub" and "reboot" but it still did the same thing. Commented Dec 28, 2020 at 21:17
  • Hmm I am wondering will this work: in RHEL/CentOS: sudo grub2-mkconfig -o /etc/default/grub In Ubuntu: sudo update-grub2
    – Sysadmin
    Commented Jan 5, 2021 at 23:45
  • Additionally check this link: unix.stackexchange.com/questions/414655/…
    – Sysadmin
    Commented Jan 5, 2021 at 23:47
  • The menu entries for the different kernels in my grub.cfg are identical except for the names of the kernel and initrd files. So if the root= is correct on the generic kernels (which I can boot from), shouldn't it be correct on the self-compiled ones as well? Commented Jan 6, 2021 at 5:46
  • As for the filesystem driver being a module, I checked using diff and the configuration files for the kernels I built are identical to the ones for the kernels I am running except for the new stuff being unset (as they are by default). The ext4 driver is marked Y. Commented Jan 6, 2021 at 5:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .