mini_kernel is a small 32-bit x86 educational operating system written in NASM and C. It is designed to teach low-level concepts such as booting, protected mode, interrupts, memory management, ELF loading, and basic user-space execution.
The project builds a raw disk image containing a boot sector and a minimal protected-mode kernel. It is intentionally small and approachable, making it a good base for learning how an OS starts, loads code, handles processes, and interacts with hardware.
mini_kernel already includes a solid base for a minimalist x86 operating system. The current implementation focuses on early boot, processor setup, memory management, and basic user-mode execution.
- Protected-mode boot process with GDT setup
- BIOS memory map collection via E820
- Basic kernel loading from disk using BIOS LBA reads
- Transition from 16-bit real mode into 32-bit protected mode
- TSS and task-switch related setup for user mode
- Basic page frame / physical memory management
- Simple allocator and memory inspection helpers
- Scheduler and context switching support for cooperative task execution
- Process lifecycle helpers including creation, exit, wait, sleep, and yield semantics
- User-space entry and return-to-user flow
- VGA text-mode console driver
- Keyboard interrupt handling and input support
- PIT timer integration for scheduling and timing primitives
- Exception and interrupt dispatch infrastructure
- ELF user program loading and execution
- User-mode syscall interface
- Process creation from ELF images
- Example user programs and shell-like environment
- Build system for assembling bootloader and kernel objects
- QEMU-based execution for testing and debugging
- In-kernel test helpers and debugging-oriented utilities
These features are intentionally small and educational, which makes the codebase easier to follow while still demonstrating how a real kernel is assembled.
- boot/ — bootloader source and startup code
- kernel/ — kernel logic, drivers, scheduler, memory, and syscall code
- user/ — sample user programs and user-space utilities
- link.ld — linker script
- makefile — build instructions and target definitions
Install the dependencies needed to build and run the OS:
sudo apt install nasm gcc-multilib binutils qemu-system-x86Required tools:
- nasm
- gcc with 32-bit support
- ld / binutils
- qemu-system-i386
From the repository root:
makeThis creates the boot sector and kernel artifacts and produces a raw disk image called disk.img.
make runOr directly:
qemu-system-i386 -drive format=raw,file=disk.imgStart QEMU with a GDB stub:
qemu-system-i386 -S -gdb tcp::1234 -drive format=raw,file=disk.imgThen connect in another terminal:
gdb -q -ex "target remote :1234" kernel/kernel.elfmake/make all— build everythingmake boot— assemble the boot sectormake kernel— build kernel components and link ELF binariesmake run— launch the OS in QEMUmake clean— remove generated files
This project is intentionally small, but there are several areas where contributors can help extend it. The following features are great candidates for new pull requests and experiments:
- Shell arguments
- ps command
- File descriptors
- Pipe support
- stdin/stdout redirection
- Filesystem
- Better scheduler
- Signals
- Dynamic memory improvements
- SMP
- Networking
If you want to contribute, a few particularly useful areas are:
- userland shell and command parsing
- process management and scheduler improvements
- ELF loading and memory safety
- keyboard/console UX improvements
- documentation and debugging notes
- kernel testing and cleanup
Contributions are welcome. A good workflow is:
- Fork the repository.
- Create a focused feature branch.
- Keep changes small and understandable.
- Build the project with
make. - Open a pull request with a clear explanation of the change.
Please keep patches targeted and document any new behavior or limitations in the README or relevant source comments.
This project is provided for educational and experimental purposes. There is no explicit license file yet, so if you plan to distribute or accept external contributions widely, it is recommended to add one.