Building A Kernel From Scratch
Why would you want to build a custom Linux kernel (well, a rootfs, kernel, and a bootloader)? There are two reasons:
Customization (fun): You want to maintain a custom OS that includes non-standard features and drivers. You want to learn how a kernel is built and compiled.
Performance: You want to deploy a stripped-down distribution on an embedded device or other constrained environment and need to remove unnecessary components. Or other specialized hardware.
Minikube (Kubernetes on your laptop) needed a minimal Linux distribution in order to minimize start-up times and resource usage on your laptop. We started by just using the same image that Docker Machine (the precursor to Docker Desktop) used. It already included all of the kernel modules, settings, and packages needed to run Docker. However, over time, we needed to support more custom kernel parameters and modules for Kubernetes-specific features (e.g., custom container runtimes). So we ended up building our own minimal embedded Linux distribution.
What options do you have? Here are some tools (we used Buildroot at the time).
Buildroot — a set of Makefiles and patches that simplify and automate the process of building a complete and bootable Linux environment for an embedded system.
Yocto — an open-source collaboration project that provides templates, tools, and methods for creating custom Linux-based systems for embedded products, offering a high level of customization, support for various architectures, and numerous software packages. You can find yocto-built kernels in BMWs, Lexmark printers, Go Pro, and LG webOS TVs.
OpenWrt — Based on Buildroot, but focused on network applications.