Skip to content

01 - Toolchain Setup: Setting Up Your OS Development Environment on WSL Ubuntu

Let's start by getting your development environment ready for building an operating system. Having the right tools set up properly is crucial for low-level development - you'll need them to compile, assemble, and test your custom OS components.

We'll be setting everything up in Windows Subsystem for Linux (WSL) using Ubuntu. This gives us access to all the Linux tools we need while keeping things convenient on a Windows machine.


What's a Toolchain?

When we talk about a "toolchain," we're referring to the collection of software tools you need to build your project. For OS development, here's what we'll be working with:

  • Compiler (GCC): Converts your C code into machine code that the processor can understand.
  • Assembler (NASM): Turns assembly language into machine code.
  • Linker (part of GCC): Combines all your compiled code and libraries into a working executable.
  • Emulator (QEMU): Lets you run and test your OS without needing a separate physical computer.
  • Utility Tools (GRUB, xorriso): Help create bootable disk images.

What You'll Need

Before we start, make sure you have:

  • Windows Subsystem for Linux (WSL) with Ubuntu installed and working. If you haven't set this up yet, check out Microsoft's guide: Install WSL.
  • Basic familiarity with the Linux command line.

Installing the Tools

Open your WSL Ubuntu terminal and let's install everything we need using apt (Ubuntu's package manager).

1. Update Your System

First, let's make sure your package lists are current:

sudo apt update
sudo apt upgrade

2. Install build-essential

This package gives us the GNU Compiler Collection (GCC), GNU Make, and other essential development tools we'll need for compiling our kernel code.

sudo apt install build-essential

3. Install nasm (Netwide Assembler)

We'll use nasm for writing assembly code, especially for the bootloader and any low-level routines in our OS.

sudo apt install nasm

4. Install qemu (Emulator)

QEMU is an amazing open-source emulator. We'll specifically use qemu-system-i386 to simulate an x86 computer, which gives us a safe environment to test our OS without risking our actual machine.

sudo apt install qemu-system-x86 qemu-utils virt-manager bridge-utils

5. Install GRUB Utilities

Even though we'll start with our own bootloader, these GRUB tools (like grub-mkrescue) are really useful for creating bootable ISO images. You might want them later as your OS gets more complex.

sudo apt install grub-pc-bin mtools

6. Install xorriso (ISO Image Creator)

This tool creates ISO 9660 filesystem images - basically, it packages your bootloader and kernel into a .iso file that QEMU can boot from.

sudo apt install xorriso


Test Everything Works

Let's verify that all our tools installed correctly by checking their versions:

gcc --version               # Shows GCC version
nasm -v                     # Shows NASM version
qemu-system-i386 --version  # Shows QEMU version for i386
grub-mkrescue --version     # Shows GRUB mkrescue version
xorriso --version           # Shows xorriso version
If you see version numbers without any errors, you're all set!


Create Your Project Directory (Optional)

It's a good idea to create a dedicated folder for your OS project:

mkdir ~/hashx86
cd ~/hashx86
This will be your workspace where you'll keep all your source code, build scripts, and the bootable images you create.


You're Ready!

That's it - your OS development environment is ready to go! You now have all the tools you need to compile, assemble, link, and test your custom operating system.

Next up, we'll dive into Bootloader Essentials, where we'll start writing the code that runs when your computer first boots up.