Skip to content

Vui-Chee/kernel-dojo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

105 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kernel Dojo

A hands-on environment for learning Linux kernel development. Build, run, and hack on the kernel inside QEMU — no risk to your host system.

What's included

  • Automated kernel build — fetches kernel source and builds a QEMU-bootable image with one command
  • QEMU runner — boots the kernel with networking, SSH, and module loading pre-configured
  • Example modules — annotated kernel modules to learn from and extend
  • Scaffolding — quickly create new modules based on a working template

Prerequisites

Install dependencies for your distro:

make install

Supports apt, dnf, pacman, and zypper. You'll also need clang, lld, and llvm installed separately.

Getting started

1. Get the kernel source

make clone                  # clones linux-stable at the pinned version

The default is Linux 6.18.6. Override with:

make clone KERNEL_VERSION=6.12.0

2. Build the kernel

./tools/build.sh -d linux-6.18.6

This produces a bootable image at linux-6.18.6/arch/x86/boot/bzImage.

3. Boot in QEMU

make run

Connect via SSH on port 52222. Override CPU count and memory:

NRCPU=4 MEMORY=8192 make run

Writing kernel modules

Build a module

make mod -E M_DIR=modules/process-times/

Example modules

Module Description
bare-module Minimal loadable module — a clean starting point
process-times Captures per-process CPU times via a kernel module

Project layout

kernel-dojo/
├── modules/           # Kernel modules
│   ├── bare-module/    # Template module
│   └── process-times/  # Example: process CPU time tracking
├── tools/
│   ├── build.sh        # Kernel build script (clang/LLVM)
│   ├── start_qemu.sh   # QEMU launcher with networking
│   ├── genmake.sh      # Makefile generator for modules
│   └── host_lib.sh     # Shared shell utilities
├── readings/           # Notes and references
├── linux-6.18.6/       # Kernel source (after make clone)
└── Makefile

Useful make targets

Target Description
make install Install build dependencies
make clone Clone the kernel source
make run Boot the kernel in QEMU
make scope Build and open a cscope index of the kernel
make clean Clean the kernel build

About

Learn kernel discipline with study and practice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors