Post

Linux Kernel Build Configuration and Modules

Lessons learned regarding Kconfig, Kbuild, and managing dynamic kernel modules.

Linux Kernel Build Configuration and Modules

Introduction

After finishing the QEMU + libvirt setup and the first simple “hello world” modules, I moved on to Tutorial 3: Build Configuration and Modules from the FLUSP series.

This was the moment everything started to feel more real. I learned how to properly configure the kernel, add new modules, and — best part — load/unload them without rebooting. The modularity of Linux is seriously impressive.

Note: I started on Ubuntu 24.04 but ran into some stability issues, so I switched my main dev environment to Debian 13 (Trixie). Much happier now.


Tutorial 3: Build Configuration and Modules

What I Did

I added a few custom modules (simple_mod and friends) inside the IIO kernel tree.

Kconfig vs Kbuild (finally clear!)

  • Kconfig: The menu. Defines the option name, description, type (tristate), and dependencies.
  • Kbuild: The builder (specialized Makefile). Decides whether to compile the code as built-in (y), module (m), or not at all (n).

Super simple once you see it in practice.

I used make menuconfig to set my module as m (module), then rebuilt.

Workflow Improvements

  • First full rebuild after adding the new module took ~2 hours.
  • After that, kw build + modules_prepare made everything way faster.
  • I only rebuilt the .ko file and copied it straight into the VM with kw — huge time saver.

Troubleshooting

One small gotcha: the tutorial mentions guestunmount $VM_MOUNT_POINT, but my activate.sh didn’t have that variable yet. I just used the full path instead:

1
sudo guestunmount "${VM_DIR}/arm64_rootfs"

Worked perfectly after that.

What I Learned

  • The tristate system (y/m/n) is the heart of kernel configuration.
  • Kconfig = choices, Kbuild = actual build rules.
  • Dynamic modules are magical — change kernel behavior on the fly with modprobe.
  • kw + modules_prepare is the real productivity hack for kernel dev.

Licensed under CC BY 4.0.

This post is licensed under CC BY 4.0 by the author.