Back to Blog

Building zorbaOS, a 32 Bit Operating System Kernel From Scratch

Operating Systemsx86CSystems Programming

Github Link: https://github.com/sarbagyag/zorbaOS-kernel-dev.git

zorbaOS started from a simple question that would not leave me alone: what actually happens between pressing the power button and seeing a command prompt appear. Every layer of an operating system usually sits hidden underneath something else you already trust, so I decided the only honest way to understand it was to write every one of those layers myself.

Getting Into Protected Mode

The first real milestone was writing a custom bootloader in assembly. It has to handle real mode initialization and then carry out the transition into 32 bit Protected Mode, which means building the Global Descriptor Table and Interrupt Descriptor Table by hand rather than relying on anything the processor gives you for free.

Memory, Files and Multitasking

Once the kernel had a foothold in Protected Mode, I built page based virtual memory on top of it, along with a custom heap allocator so processes could be isolated from one another properly. On top of that sits a virtual file system loosely inspired by Linux, backed by a FAT16 driver, plus a scheduler that can preempt running tasks and an ELF loader capable of running user space programs across Ring 0 and Ring 3.

Making It Feel Real

None of this matters much if it stays purely theoretical, so I wired up keyboard and PIC interrupt drivers and built an interactive command line shell on top of everything else. Typing a command and watching the kernel actually respond to it, after months of work that mostly lived in a debugger, is still the most satisfying moment this project has given me so far. There is still plenty left to build, but zorbaOS already feels like a real, if small, operating system rather than an exercise.