Table of Contents
Minimalistic guide to build a Kernel (only)
Introduction
Brief guide to configure, compile and install a kernel. I do this all as root in /usr/src, others do all steps except install in /home/user/somewhere as user. If I'm going to use the Kernel to control my computer I might as well trust the build process. So this guide assumes as ROOT and /usr/src. It is mainly intended as my reference to other howto's that requires building a Kernel first.
This howto assumes kernel-5.16.9. Obviously you should use the newest appropriate version and use those version numbers.
summary:
cd /usr/src tar -xvf linux-5.16.9.tar.xz cd linux-5.16.9 make clean && make mrproper cp ../config-custom ./.config make menuconfig make -j3 make modules && make modules_install cp System.map /boot/System.map-5.16.9_custom-v1 cp .config /boot/config-5.16.9_custom-v1 cp arch/x86/boot/bzImage /boot/vmlinuz-5.16.9_custom-v1
Preparations
Download the latest Kernel stable from:
https://kernel.org/
Check the signature.
Optional: patch
cd /usr/src tar -xvf linux-5.16.9.tar.xz cd linux-5.16.9 make clean && make mrproper cp ../config-custom ./.config
You only need to do mrproper, not clean, I just do it out of habit. Cp assumes you already have a useful config-custom file in /usr/src, or you could cp /boot/config-generic.
Configure
If you don't have a good configuration file for the particular computer you're on, you could use make localmodconfig (DON'T) before menuconfig to make one from scratch. Or you could do the opposite and make (copy) one from config-huge, or if you intend to use initrd, config-generic. Note, if you to this, you have to ADD lots of stuff with localmodconfig (that you need or might need) or you CAN remove alot of stuff (you don't need) from config-generic or config-huge. If you intend to not use an initrd, you need to build into the Kernel anything you need, and you can build into or as modules(preferably) things you might need.
make menuconfig
Save the configuration.
Compile
make -j3
Where 3 is 3 cores. Use more or less by have/needs.
Modules
make modules && make modules_install
You don't need to do make modules, only modules_install, I just do out of old habits and precaution. You might want to make headers_install here once in awhile.
Install
cp System.map /boot/System.map-5.16.9_acer-v5 cp .config /boot/config-5.16.9_acer-v5 cp arch/x86/boot/bzImage /boot/vmlinuz-5.16.9_acer-v5
If you want to make and use initrd, this is the time.
Then add your custom entry to the bootloader.
Sources
* Originally written by Zeebra