Compiling your own kernel
In short: You can build the kernel from source yourself to switch features on or off, make it smaller or optimise it.
In more detail: You download the source code from kernel.org, choose options with menuconfig and compile.
In detail
tar xf linux-6.12.tar.xz && cd linux-6.12
cp /boot/config-$(uname -r) .config # config of the running version
make olddefconfig
make menuconfig # adjust options
make -j$(nproc)
sudo make modules_install
sudo make install # copies to /boot, updates bootloader- Requirements: gcc, make, flex, bison, libssl-dev, libelf-dev, bc.
- Duration: from a few minutes to over an hour, depending on options.
- Distribution ways: Debian:
make bindeb-pkgcreates.debpackages, Fedora/Arch have their own packages. - Risk: wrong options lead to systems that do not boot, so always keep a working kernel in the boot menu.
- Alternative: ready-made kernel variants (Zen, XanMod, Liquorix), see Alternative kernels: Zen, XanMod, Liquorix and hardened.
- Sign modules with Secure Boot.
See also: Building software from source (make, CMake), Kernel modules and drivers