Skip to content

Tiny Kernel

build the tiniest possible kernel

today we gonna build the tiniest possible linux kernel, just for fun, and learning purposes. linux build system already comes with a config option, that leaves you with a very bare minimum kernel possible:

make tinyconfig

this will create .config file, with the absolutly needed features only. then we should at least enable some other config just to have something logged in the screen, the features we gonna need are:

  1. tty
  2. printk
  3. initrd
  4. executable formats
  5. proc fs

you can easily find those, if you search with menuconfig, by pressing /, and write what are you looking for.

let's compile it:

make -j$(nproc)

then we gonna need an initramfs, to test with, let's use the default one that comes with the distribution:

qemu -kernel arch/x86/boot/bzImage -initrd /boot/initramfs-linux.img -append "init=/bin/bash"

after that you should get a shell prompt. there you have it the smallest possible kernel.