Vanilla kernel compiled from source won't boot

I’m bisecting a driver issue and I’m trying to compile a kernel from source following the instructions at Building a custom kernel - Fedora Project Wiki

Compilation works fine, but when I’m booting into the kernel, grub aborts with a mysterious ../../grub-core/kern/mm.c:376: out of memory. error.

I have no idea what’s going on. The only indication there’s something different is that the initramfs generated is much larger, for some reason, than a default Fedora kernel:

-rw-------. 1 root root 223361240 Feb 17 22:01 /boot/initramfs-5.15.0-sph-bisect-audio-suspend+.img
-rw-------. 1 root root  48905010 Jan 24 10:39 /boot/initramfs-5.15.16-200.fc35.x86_64.img

Of course it’s not a memory problem, I have 64 GB on my system. Why can’t I compile and run a kernel from scratch? What am I missing?

I’ve removed the quiet option, and found out the kernel panics on boot with this error: Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

I’m using LUKS, the cmdline is exactly the same as the working kernel, why does the custom one not boot at all? What is the procedure to compile a bootable Fedora kernel from the stable torvalds/linux tree?

1 Like

Your initramfs appears to be 223 MB vs the default 48 MB. That is quite a bit larger than the default.
I am not sure I am reading that right in size though. Could you post that again but use ls -lh to get the size with the units displayed.

How you create the .config file when building the kernel? Are you creating by your self?

You could use standard fedora .config as starting point. You could get from /boot/ and use any file with name config-5.15.* copy to your kernel folder and rename it as .config. Load the config and adjust it if necessary. At least it will avoid to compile unnecessary config that not needed for your system.

The other things, if you’re sure already make correct boot config for your kernel, make sure to disable secure boot when booting to your custom kernel.

Maybe you also want to read this Fedora doc.

No, that’s 223 MB. It’s just kernel modules, it never reaches into the gigabytes.

I’m using the default config from Fedora. I’m actually trying to compile v5.15.16 from source, using /boot/config-5.15.16-etc (sorry I’m on mobile) that’s provided by the Fedora kernel. There’s a couple of options that are missing but I’m 100% positive they are not the cause of the issue (mostly obscure modules and platform options).

I haven’t tried disabling secure boot, but I would expect any other error that the kernel complaining it can’t find my root volume by UUID.

Nope, secure boot wasn’t and isn’t enabled.

And yes, I’ve followed that document to the letter, as stated in my original post :slight_smile: Which is why I’m wondering if there’s some important instruction that’s missing, yet I’ve compiled a few kernels in my time and I’ve never needed much more than running make and all the appropriate steps.

Any more ideas?

I found the issue, it was indeed because of initramfs being too large. Apparently grub can’t deal with a 220 MB initramfs on a 64 GB machine from 2020 :smile:

I’ve managed to slim down the initramfs to about 50 MB by running make INSTALL_MOD_STRIP=1 modules_install before make install to have the modules stripped from any debug information, and that makes the kernel boot.

If anybody has edit access to Building a custom kernel - Fedora Project Wiki it might be worth pointing this out and saving someone 3 hours of troubleshooting.


There’s a note about it in the quick dock @oprizal referenced.

Either way that should be more clear in the doc.


You can file an issue against the quick docs here