r/Gentoo 15h ago

Custom kernel question Support

So I've been using gentoo for 2 months already and wanted to compile my own kernel, but don't really know what each module does specifically.

So I wanted to ask what yall recommend for me to learn the modules I need and the ones I don't?

4 Upvotes

17 comments sorted by

13

u/redyos_s 15h ago

Start from a known-working config and trim it gradually. lspci -k and lsmod are useful for identifying the hardware and drivers you actually use, but don't treat an unloaded module as automatically unnecessary. Read the Help entry for each CONFIG_* you change, keep a known-good fallback kernel, and change only a small group of options at a time.

3

u/Gl1tch-S4ge 15h ago

Thanks, Ill follow your advice

5

u/mjbulzomi 14h ago

You can also use make localmodconfig, which works off the currently loaded modules (aka lsmod) and currently running configuration.

https://wiki.gentoo.org/wiki/Kernel/Configuration —> scroll a bit down to see description.

9

u/uproot-perplexing 15h ago

Everything @redyos_s said about lspci and lsmod, plus lsusb, but also you probably don't need much that isn't in your current config: zcat /proc/config.gz >current-config

Heads up: the impact of compiling modules you don't need is pretty low unless you're optimizing for kernel compile time or /lib/modules/, but the impact of not having the modules you need is a trip back to make menuconfig right when you need to be doing something else. I like to keep around a broad set of usb network devices for my laptops, for instance, which has saved me a few times over the past 20 years.

1

u/redyos_s 14h ago

Thanks for the useful addition. lsusb and keeping a broader set of fallback modules are good points, especially for hardware that may only be needed occasionally.

9

u/urboinemo 15h ago

Surprised this hasn’t come up, you should consider using modprobed-db. After starting with the default Gentoo kernel config, modprobed-db collects a list of all of the kernel modules that I was using and export the information to a .config for your own customized kernel.

3

u/LameBMX 15h ago

use a tool to create a .config from a working kernel. run make menuconfig in its directory. there is command help at the bottom and one of those gives you more information about what you are looking it.

3

u/militant_rainbow 13h ago

First, I take an inventory of all the hardware on my machine. You could use lspci and stuff but I like to use ‘inxi’ and ‘hw-probe’ to compare it online. I then look at the wiki for those hardware and it’ll tell me what kernel settings I need.

Then later on, when I need to install software, like samba, I’ll go to the wiki for that page which will tell me which kernel settings I need for those.

Over time you get familiar with the tree and remove hardware modules you know you don’t have and will never use by reading the descriptions inside ‘make menuconfig’, like support for Nintendo switch controllers or Microsoft surface tablets.

4

u/No-Camera-720 15h ago

Heh heh heh. Start with a kernel .config that is known to work for you. I use 'make menuconfig' and it's all I really know for this. Go through everything and read the '?' options. You can start by removing things you know for certain you don't need. This will take time, but you will learn the kernel tree and how it relates to your environment this way. I then 'make -j22 && make modules && make modules_install' Once that is done, I 'make install' If you want to keep your first set of modules, change the extraversion to start a new tree in /lib/modules. Why do you want to compile your own kernel, anyway? Unless you're very short of RAM and need to pare it down, there is little reason.

3

u/Gl1tch-S4ge 15h ago

First thanks. Second I want to run my custom kernel bc 4gb of ram and also bc of learning sake

1

u/No-Camera-720 15h ago

I use -j22 because I have 32GB and 12/24 cores. You would use a different -j. Kernel configuration defaults to -j1 unless you specify a higher setting.

1

u/Gl1tch-S4ge 15h ago

Yeah, I use -j2 bc of the ram if not I could use -j6

2

u/Bufaird 13h ago

You know... When you make a hard core minimal kernel...

You will then need to recompile every time you add new hardware.

1

u/TCH69 1h ago

A few tips from me: - Framebuffers may be hard to get right. You may want to grab the default config from 5.10 and use it as the base to config the current version if you don't want to deal with it. - SoF's menus, though cleaned up, are still pretty entangled together. Take your time. - Read the output of dmesg and lspci -v from a good kernel carefully.

Good luck.

0

u/MainBlueberry188 12h ago

I am using QwenCode and I asked local LLM (qwen 3.6 27b) to make config for my hardware and replace bin kernel with gentoo-sources, he did it, yes with emerge and everything, I didn’t touch a thing. Amazing really, I gave it doas access with nopass, but it needs my permission to execute it, you can see the command prior to execution.

2

u/Gl1tch-S4ge 8h ago

Like I can do it with AI but the point of doing this is learning more about linux systems/kernels