I wrote documentation about compiling the kernel
Posted by OVRTNE_Music@reddit | linux | View on Reddit | 13 comments
Hello,
Today i've dipped myself under in the world of compiling the kernel, i never compiled it before because i was scared i would overwrite the working kernel, decided to use my Debian Sid laptop for doing this, it took a while and as of writing this its still not fully compiled (i have really old hardware and 2 cpu threads to work with). I decided to write some documentation about compiling Linux, the dependencies and the most common errors while building.
Here it is:
https://salsa.debian.org/-/snippets/852
Cheers,
\~Mealman1551, Nathan du Buy
aloobhujiyaay@reddit
compiling on old hardware takes patience 😠but you’ll understand way more once it’s done
MatchingTurret@reddit
Used to take a weekend on a 2MB 386sx.
gdf8gdn8@reddit
Me too.i had already i486 with 16 MiB. Compiling for a weekend only to discover that a parameter was incorrectly configured was a bit of a pain.
ApplicationMaximum84@reddit
On my current laptop the default config takes 5 minutes, but a customised config takes up to 3 hours, with 12 jobs running - single threaded would be a pain.
ApplicationMaximum84@reddit
Whenever I compile the kernel for the first time, there are always new dependencies that popup. Still once those are fixed, the process is relatively straightforward 'defconfig' compilations are nice and fast, but a modified config takes ages - 2.5 hours the last Ubuntu kernel build I was compiling (on a 10th gen Intel 6C/12T)
wyn10@reddit
If you ever move over to Arch based there's a kernel manager for building here https://github.com/CachyOS/kernel-manager
BigHeadTonyT@reddit
Ditrokernels config is a good starting point. They support most hardware etc.
IIRC, localmodconfig only checks for loaded modules. If so, I'd have to start every process and app that requires a kernel module. Like a virtual machine, plugging in a Ventoy stick so the filesystem for it is loaded. Accessing every disk drive if the filesystem differs. I would remember it all.
Instead, what I do is start with the distro config, run menuconfig or similar, disable everything Intel (except for my NIC) and Wireless. Personal choices of course and hardware dependent. Saves a bunch of time on compiling kernel.
You can see all the options here: https://www.kernel.org/doc/Documentation/admin-guide/README.rst
Search for "make menuconfig" for example. Only 1 in the whole document. You will see the rest of them and short explanations too.
About "make mrproper", you should run it as soon as you have extracted the kernel and changed to its directory, the source code. Linux kernel team IIRC, gives no guarantees it will be squaky clean. There might be some crap left behind. make mrproper cleans it up. Yes, it also deletes the .config for the kernel, if you've made one or extracted from distro. You can rename it, .config1 or whatever, it will not be removed. Afterwards you can copy it back as .config. I say copy because you might not get everything right the first time. I just keep adding numbers to the .config file so I know what is the most current. And rename that to .config. If I did mess up a kernel compile and ended up with none-working stuff, I will run make mrproper again in kernel sourcecode directory. Then copy latest .config to .config. Adjust the kernel options via make menuconfig or similar and try again.
You can also add a name to the end of the kernel with "LOCALVERSION". You can look for it in menuconfig or similar with Shift + 7. Double-click it or something to be able to type text. I was lazy and named mine "Mine" in this example after kernel compilation is done, to install said kernel on Manjaro:
Ready for reboot and testing. The Grub menu will say -Mine at the end, easy to spot among the countless kernels I usually have to choose from. I tend to forget XFS filesystem support. Doesn't go so well since my OS is running XFS, doh!
I like Dracut because it is just 3 lines of commands and faster at it. Some Arch-based distros use it instead of mkinitcpio.
Of course you can expand on the kernel, by for example downloading the Zen-kernel patches and incorporating them in your kernel. You can get those from here: https://github.com/zen-kernel/zen-kernel/releases
Extract the file to kernel source directory. And run:
patch -p1 < "patchname"There should be a place in for example menuconfig where you can pick your architecture, generation of Intel or AMD CPU. Courtesy of a Zen patch. I forget exact details. Then configure the rest of the kernel, compile etc.
Ancient-Opinion9642@reddit
Once upon a time these were called FAQ’s. It has fallen out of style as more distributions were added to Linux. They were a gold mine for how-to.
Business_Flow9980@reddit
nice work documenting the process! kernel compilation can be pretty intimidating at first but you picked good distro for experimenting with it
just heads up - you might want to check the `make -j` flag usage in your docs, running too many parallel jobs on older hardware can actually make builds slower or cause them to fail from memory pressure
OVRTNE_Music@reddit (OP)
Thank you for the feedback, i will implement this in the doc.
Anantha_datta@reddit
nice. kernel stuff feels scary till u actually do it .docs like this are useful esp the error part. thats usually what trips ppl up not the steps.
OVRTNE_Music@reddit (OP)
ikr, i try to make kernel building less scary for ppl
Ok-Winner-6589@reddit
I have the source already installed, just needed this lol.
I'm checking this later, thanks tho