Building all Ubuntu extra modules - kernel compilation

Hi all,

I am reasonably experienced as a Linux user but recently, after getting a Lunar Lake laptop, I found myself in search for the bleeding edge kernel because the support for the platform (even on 6.11) is poor.

I have never really compiled an amd64 kernel before but after reading some guides, this is the approach that worked:

wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.13.tar.gz
tar -xf linux-6.13.tar.gz
cd linux-6.13/
cp -v /boot/config-$(uname -r) .config # copy my kernel config
make localmodconfig # not sure what this does, probably applies my config to the kernel/generates the final one
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
scripts/config --set-str CONFIG_SYSTEM_TRUSTED_KEYS ""
scripts/config --set-str CONFIG_SYSTEM_REVOCATION_KEYS ""
fakeroot make -j7 # this built the kernel
nice make -j7 bindeb-pkg # this made the kernel debs
cd ..
sudo apt install ./linux-image-6.13.0_6.13.0-2_amd64.deb ./linux-headers-6.13.0_6.13.0-2_amd64.deb ./linux-libc-dev_6.13.0-2_amd64.deb

Surprisingly, there were no errors and the system booted, and using the laptop was a far better experience (because of the default power plan on Asus Zenbook S14 now changed to a slightly higher one). But there was a problem: since Ubuntu splits its kernel-related debs into the normal one and “modules-extra”, I seem to have only built the standard set by copying my current config. But extra modules provide basic functions, like running Docker or using external USB drives.

Now the question is: how to find out what these extra modules are and either build a deb with them, or just integrate all of them with my kernel and rebuild it? I am not able to find anything about this.

I am aware of the make menuconfig command, but I would be shooting in the dark by trying to find them there.

This configures the kernel build to only include the modules currently loaded on the build system, overwriting your copied config. Try

cp -v /boot/config-$(uname -r) .config
make oldconfig

instead. And be prepared to wait much longer for the build to finish!

Edit: This will ask you to choose y/n/m (yes - builtin, no, yes - module) for every config option that’s new (or changed) in the new kernel compared to the old config. It can be tricky to know how to answer. In general, say n to new device drivers, and use ? to get help on everything else. Or just press Enter for the default value, but it’s usually good to at least read the help text first.

See the relevant kernel documentation for the meaning of localmodconfig, oldconfig et cetera.

1 Like

Thanks. Now, would it still include the UAS module, for example, even if there wasn’t a USB drive connected at that moment?

I’ve read the documentation and it seems that make oldconfig would be even more minimal, but I am not sure.

… and indeed, the kernel deb is much heavier now. Hopefully it contains all the useful modules! Will test later today.

1 more thing - I’ve changed generic x86 to MCORE2 (Core 2/newer Xeon) and disabled anything related to AMD or other x86 chips. Would it make anything faster, or would it just make the kernel smaller?

it works, thank you, @homeserver78! I can finally run a proper OS on this laptop.

Now the only thing left is to self-sign it (I had to remove the links to the Canonical certs as obviously I don’t have them). I’ve seen some tutorials and it looks quite involved, but doable.

1 Like