hacker tutorialscourse catalogue

Courses / Course 04 · Os

Build an operating system

You end up withA Unix shell you wrote; a small RISC-V operating system with processes, paging, user mode, system calls and a file system; an x86-64 kernel in Rust with interrupts, paging and a heap allocator; xv6 extended through MIT's nine labs; and Linux kernel modules you built and loaded, with enough Linux internals to read the kernel's source.

  • 23 sources
  • 401 HN threads
  • 29,894 points
  • 2008–2026
  • 6–9 months part-time

Data pulled 2026-11-08 · time estimates are editorial

Why build one when the agent never touches the kernel? Because every bug that isn’t in your code is in this layer: the process that won’t die, the memory that’s “free” but not available, the container that sees a different filesystem, the syscall that’s suddenly slow. After this track, fork, page faults, file descriptors and context switches are things you’ve implemented, not words in a stack trace. Hacker News has voted these tutorials up since 2008. Every step below shows its HN score and quotes what HN said.

How this track is ordered, and why it skips the boot sector. Most OS tutorials start by writing a 512-byte bootloader for the legacy PC BIOS. HN’s experienced hobbyists keep warning against that:

HN exDM69, 2025 · comment

“Because if you want to write an OS, don’t write a bootloader first. This article essentially describes a stage 1 bootloader on top of legacy BIOS firmware. It will teach you about historical x86 minutiae, which is nothing but a hindrance if you want to understand OS concepts.”

So the track goes from the outside in: the system-call interface first, then a whole small OS on RISC-V (which has none of x86’s legacy boot steps), then x86-64 in depth with a ready-made bootloader, then a real teaching Unix, then Linux. The boot-sector tutorials are an optional detour in Stage 3.

How to read the receipts.

  • Points are summed across every HN submission of the same URL. For multi-part works on one site (Philipp Oppermann’s series, Linux Insides, Gustavo Duarte’s articles), that includes parts submitted on their own.
  • “Submitted N×” means HN rediscovered it N times.
  • Quotes come from the highest-ranked top-level comments in those threads, and a quote is sometimes a criticism. Quotes keep the commenter’s spelling.
  • Steps are ordered for learning, not by points.
  • Times are our estimates, not the authors’. They assume evenings and weekends, and a reader who writes C comfortably. Stage 3 also needs Rust.
  • Hardware. Everything runs in QEMU on a laptop. No step needs a spare machine.

Optional on-ramp: How computers boot, and what a program looks like in memory (manybutfinite.com) · Gustavo Duarte

2,369 points across 45 submissions of his internals articles (2008–2023) · Free · articles · ~2 evenings

Short, illustrated articles on what happens from power-on to a running kernel, how a process is laid out in memory, and how the kernel manages memory. Read How Computers Boot Up, Anatomy of a Program in Memory and How the Kernel Manages Your Memory.

HN AceJohnny2, 2014 · comment

“Gustavo Duarte’s (not to be confused with Androider Matias Duarte) blog posts are awesome.”

Stage 13–5 weeksThe OS from the outside

1.

Operating Systems: Three Easy Pieces (pages.cs.wisc.edu) · Remzi and Andrea Arpaci-Dusseau

1,199 points, submitted 25× (2013–2026) · Free online (chapter PDFs); print and a single PDF are paid · C · read alongside the whole track

The textbook for this track, in three parts: virtualization (processes, scheduling, memory), concurrency (threads, locks) and persistence (disks, file systems). Read the virtualization chapters now, and keep reading as the later stages reach each topic. Its companion repository, ostep-projects, has graded projects in C, including a shell and several xv6 kernel projects.

HN schaefer, 2021 · comment

“Even with 20 years writing software professionally under my belt, the ways this book shifted my perceptions on topics I assumed I knew well was surprising!”

HN idolaspecus, 2021 · comment

“There was a long period of time after I “learned to code” where everything still seemed like magic. Working through this book for 10 weeks in my OS course at school was when the magic finally become real and concrete.”

2.

Write a Shell in C (brennan.io) · Stephen Brennan

876 points, submitted 8× (2016–2024) · Free · C · ~1 week

A working shell in a few hundred lines: read a line, split it, fork, exec, wait. Then extend it yourself with pipes and redirection, using the processes-shell project from ostep-projects as the spec.

HN chubot, 2016 · comment

“This article is good in that it shows that starting processes boils down to the system calls fork(), exec(), wait(), etc.”

HN moyix, 2016 · comment

“A nice complement to this article is the MIT 6.828 shell exercise. It provides the command loop and parsing for you, and then has you implement command execution, redirection, and pipes.”

Alternative: Writing a Unix Shell · Indradhanush Gupta · https://indradhanush.github.io/blog/writing-a-unix-shell-part-1/ · 407 points, submitted 4× (2017–2018). A slower multi-part series that builds the same loop step by step. “This is a great illustration of how non-trivial a production quality shell is.” (pacaro, 2017 · comment)

Stage 22–3 weeksA whole small OS

3.

Operating System in 1,000 Lines (operating-system-in-1000-lines.vercel.app) · Seiya Nuta

1,061 points, submitted 2× (2025–2026) · Free (CC BY 4.0) · C on 32-bit RISC-V, in QEMU · ~2–3 weeks

A complete small OS, end to end: boot, exceptions, a memory allocator, processes and context switching, page tables, user mode, system calls, a disk driver and a file system, with a shell on top. It’s the whole map at small scale before Stages 3 and 4 fill in each region.

HN nuta (the author), 2025 · comment

“I wrote this book so you can spend a boring weekend writing an operating system from scratch. You don’t have to write it in C - you can use your favorite programming language, like Rust or Zig.”

HN exDM69, 2025 · comment

“Based on my experience in “hobby” OS programming, I would add setting up GDB debugging as early as possible.”

Alternative, in Rust: The Adventures of OS: Making a RISC-V Operating System using Rust · Stephen Marz · https://osblog.stephenmarz.com/ · 1,017 points across 25 submissions of its chapters (2019–2023). “I’ve been following along with no prior Rust or OS programming knowledge and have found it immensely refreshing.” (StanAngeloff, 2020 · comment). The caveat: “My only criticism is that sometimes there’s parts in your tutorial that are missing but present in your os.” (webgoat, 2020 · comment)

Stage 34–6 weeksx86-64 in depth

4.

Writing an OS in Rust (os.phil-opp.com) · Philipp Oppermann

5,220 points across 55 submissions of its posts (2015–2026) · Free · Rust · ~4–6 weeks

A 64-bit x86 kernel, one post at a time: a freestanding binary, a minimal kernel booted with the bootloader crate, VGA text output, testing inside QEMU, CPU exceptions, double faults, hardware interrupts, paging, heap allocation, allocator designs, and async/await multitasking. This is the depth on interrupts and page tables that Stage 2 skimmed.

HN miohtama, 2019 · comment

“Not only this is interesting well understandable Rust code for non-Rust developer, but it is also one of the best tutorial how page tables work on modern PC CPUs.”

HN JesseWright, 2019, comparing it with the OSDev wiki · comment

“Phil’s articles seems so much more accessible for someone just wanting to dip their toes in the water.”

Alternatives in C (32-bit x86):

  • The little book about OS development · Helin, Renberg · https://littleosbook.github.io/ · 1,290 points, submitted 11× (2015–2025) · Free. “I am very impressed with the quality of this document.” (samwilliams, 2016 · comment). The caveat: “Unfortunately this book has the classic fault of osdev tutorials: lots of talking about x86 minutiae, very little osdev.” (netbsdusers, 2025 · comment)
  • Operating Systems: From 0 to 1 · Tu Do · https://tuhdo.github.io/os01/ · 1,182 points, submitted 8× (2017–2025) · Free. Strongest on reading the Intel manuals, ELF, linking and debugging on bare metal. Parts 1 and 2 are published; part 3 is still a plan. The caveat: “bit sad in the era of 64 bit computing still every resource is at most about protected mode.” (vectorEQ, 2018 · comment)

Stage 410–14 weeksA real teaching Unix

5.

MIT 6.1810: Operating System Engineering, with xv6 (pdos.csail.mit.edu)

2,425 points across 41 submissions of the course and xv6 pages (2011–2026) · Free: labs, the xv6 book and source are public · C on RISC-V, in QEMU · ~10–14 weeks

MIT’s undergraduate OS course (formerly 6.828 and 6.S081). xv6 is a re-implementation of Sixth Edition Unix, small enough to read in full alongside its book. The nine labs have you change it: Unix utilities, system calls, page tables, traps, copy-on-write fork, a network driver, locks, the file system, and mmap. Each lab ships with tests you run yourself. Use the 2025 edition: the Fall 2026 schedule was still under construction when this track was checked.

HN lnsp, 2022 · comment

“I do not consider myself an expert in operating systems or C, but digging through the xv6 source code is quite fun, the code is easily readable and very newby friendly.”

HN timsally, 2014, recommending 6.828 and xv6 · comment

“You are only 9,000 lines of code away from fully understanding basic operating systems concepts!”

HN’s caveat (about OS courses in general, from a student of a similar course built on Pintos): one classmate’s description was “a crash course in enabling and disabling interrupts in order to prevent segfaults and pagefaults.” (the_real_me, 2022 · comment). Self-learners get the tests but no course staff, so budget time for debugging alone.

Lighter alternative: the xv6 projects in ostep-projects (step 1), which UW-Madison uses with OSTEP. “The projects in their class at the University of Wisconsin-Madison were mainly making edits to the xv6 OS.” (bgschulman31, 2022 · comment)

Stage 55–8 weeksInto Linux

6.

The Linux Kernel Module Programming Guide (sysprog21.github.io) · Salzman, Burian, Pomerantz, Mottram, Huang

1,289 points, submitted 7× (2008–2024) · Free · C · ~2–3 weeks

Build and load modules into a running Linux kernel: character devices, /proc and sysfs files, ioctl, blocking processes, interrupt handlers. It’s kept current for modern kernels (the page was last updated in September 2026) and includes a QEMU-based setup, so a broken module doesn’t take down your machine.

HN donpdonp, 2024 · comment

“A detailed, hands-on, build a kernel module right away kind of tutorial. Bravo.”

7.

Linux Insides (github.com) · 0xAX

4,299 points across 85 submissions of its chapters (2015–2026) · Free · reading Linux’s C and assembly · ~3–5 weeks

How the real kernel boots, initialises, handles interrupts and system calls, keeps time and manages memory, traced through the actual source. After xv6 it’s readable: you know what each piece is for.

HN fn-mote, 2022 · comment

“It includes details like what bits you need to set in order to enable a particular paging mode, so it’s really enough detail to actually do something.”

Optional: go further

Writing a file system from scratch in Rust · Carlos Galdino · https://blog.carlosgaldino.com/writing-a-file-system-from-scratch-in-rust.html · 546 points, submitted 2× (2020–2023) · Free · ~1–2 weeks. An ext4-inspired file system with a superblock, block groups and inodes, mounted through FUSE. Do it after the xv6 file-system lab. “for my money, this is the best way to describe the high level function and behavior of a filesystem that I have ever seen.” (unethical_ban, 2020 · comment). The caveat: it teaches the classic design. “When files that can be fragmented regularly reach sizes in the gigabytes, using extents is the best way to track their data blocks in an efficient manner.” (didgetmaster, 2023 · comment)

Linux From Scratch · https://www.linuxfromscratch.org/ · 2,330 points, submitted 14× (2011–2026) · Free · ~1–3 weeks. Not a kernel tutorial: you build a whole Linux system from source, toolchain first. It shows what a distribution is made of. “whenever someone asks me what they should read to get a deeper understanding of what a Linux distribution is, I point them to this.” (steve1977, 2026 · comment). The caveat: “But each time it just turned into a copy-incomprehensible-commands-into-the-terminal exercise at some point, and I lost motivation.” (sieste, 2024 · comment)

Build the machine your OS runs on: emulators. Every kernel in this track ran on hardware QEMU pretended to be. An emulator is that pretence written by you: a fetch-decode-execute loop, memory, a timer, a UART, and the traps and interrupts the kernel depends on. The three steps below grow from a weekend toy to a machine that boots the xv6 you studied in Stage 4.

Write Your Own Virtual Machine · Justin Meiners and Ryan Pendleton · https://www.jmeiners.com/lc3-vm/ · 1,235 points, submitted 9× (2018–2026) · Free · ~a weekend. An emulator for the LC-3, a 16-bit teaching computer, in about 250 lines of C, which ends by playing 2048 and a roguelike. Its trap routines, the LC-3’s keyboard and console calls, are the tutorial’s own picture of an operating system: “trap routines which you can think of as the operating system or API for the LC-3.” “This will be a fun weekend project for me” (tombert, 2018 · comment). The caveat is the machine itself: “Alas, educational architectures like the Brookshear Machine and Little Computer look nothing like real ones, making them worse than useless” (saithound, 2024 · comment). Treat it as a warm-up and move to a real instruction set next.

Writing a RISC-V Emulator in Rust · Asami Doi · https://book.rvemu.app/ · 259 points, submitted 3× (2020–2025) · Free · ~4–8 weeks. A 64-bit RISC-V emulator, built up until xv6 boots on it: CSRs, privilege levels, exceptions, the PLIC and CLINT, a UART, virtio and paging. The catch is that the prose stops early. “Just a heads-up that only the first three chapters are available so far.” (quantummagic, 2025 · comment). The companion repository, rvemu-for-book, has the code for all ten steps, so read the chapters that exist, then work from the code and the RISC-V privileged spec. The author on the goal: “I already succeeded to run xv6 in my RISC-V emulator” (d0iasm, 2020 · comment)

mini-rv32ima · CNLohr · https://github.com/cnlohr/mini-rv32ima · 205 points · Free · a few evenings to read. A 32-bit RISC-V emulator in about 400 lines of C, with no MMU, that runs Linux. Read it after your own emulator works, to see how small the job can be. “I admire the dedication and consistency it takes to stick to rv32 no MMU only to be able yo fit it into very minimal environments in the end.” (bippingchip, 2022 · comment). Its README credits pimaker’s Linux in a Pixel Shader (524 points, submitted 7×), a write-up of the same kind of emulator running inside a VRChat GPU shader.

If you’d rather emulate a console. The Game Boy is HN’s usual first real system. Pan Docs (255 points, submitted 4×) is the hardware reference: “It contains all the technical documentation you need while leaving the implementation up to you.” (aquova, 2023 · comment). Robert Heaton’s Gameboy Doctor (155 points) compares your CPU’s log line by line against a known-good one for Blargg’s test ROMs. Expect the screen to be harder than the CPU: “Personally, I’ve had more trouble understanding the PPU behavior than i did about the cpu instructions and timings.” (chrsig, 2022 · comment)

The reference shelf (look things up, don’t read in order)

OSDev Wiki · https://wiki.osdev.org/ · 422 points across 30 submissions of its pages (2011–2026) · Free. The hobbyist reference for hardware details, toolchains and “bare bones” starting points.

HN exDM69, 2012 · comment

“You’ll need to build your own GNU toolchain (gcc + binutils + gdb) for cross compiling (don’t try to use the one that ships with your OS, it will subtly fail when you don’t expect it to), get an emulator (e.g. qemu or bochs) and a bootloader to get started.”

The other reference is the xv6 book, linked from the 6.1810 page in step 5.

Editorial backlog

Checked against HN on 2026-11-08 (candidates_receipts.json), not used:

  • Kernel 101 – Let’s write a Kernel (Arjun Sreedharan): 874 points over 10 submissions. HN found that it calls into C without setting up a stack: “It works out of pure luck because the compiler has decided to keep all variables in registers and changing your C compiler flags might make this fail in interesting ways.” (exDM69, 2014 · comment)
  • x86 Bare Metal Examples (Ciro Santilli): 796 points over 3 submissions. A collection of minimal examples, not a sequence. A candidate for the reference shelf.
  • Writing a Bootloader (Alex Parker, 391 points) and Writing a BIOS bootloader for 64-bit mode from scratch (thasso, 260 points): the legacy-BIOS path the track avoids.
  • How to Make a Computer Operating System (Samy Pessé): 384 points over 4 submissions. “Note that this book is half-finished and work on it has been discontinued” (Jeaye, 2016 · comment).
  • Writing an operating system kernel from scratch (Uros Popovic, RISC-V and Zig): 453 points over 2 submissions. By the author’s own account an experiment, “very rough around the edges”.
  • Writing a bare metal OS for Raspberry Pi 4 (isometimes): 456 points; Rust OS tutorials on the Raspberry Pi (rust-embedded): 213 points. Good real-hardware alternatives to Stage 3, not yet reviewed in depth.
  • Writing a Simple Linux Kernel Module (Robert Oliver): 432 points over 2 submissions. Covered better by step 6.
  • Writing a basic Linux device driver when you know nothing about Linux drivers (crescentro.se): 507 points over 3 submissions. HN pointed out the title is misleading: “The title was misleading because the author wrote a userspace Rust driver and not a Linux kernel driver in C.” (bhasi, 2025 · comment)
  • Getting started with bare-metal assembly (johv): 428 points over 2 submissions. It runs under UEFI, which HN noted isn’t bare metal in the embedded sense.
  • intermezzOS (Steve Klabnik): 67 points; unfinished when submitted.
  • ostep-projects has never been submitted to HN as a story, so it has no points of its own. It’s included as part of step 1.

Emulator candidates checked, not used: Tiny Emulators (Andre Weissflog, 734 points), Selfie (697 points; a self-compiling C compiler, RISC-V emulator and hypervisor), Weird things I learned while writing an x86 emulator (Tim Misiak, 571 points), TinyEMU (Fabrice Bellard, 542 points), Emulator 101 (520 points; an 8080 Space Invaders emulator, site unreachable on 2026-11-08), I wrote a GameBoy emulator for my hobby OS (axle, 286 points), Writing a Game Boy emulator, Cinoop (CTurt, 244 points), How to Write a Computer Emulator (Marat Fayzullin, 187 points), The Ultimate Game Boy Talk (Michael Steil, 168 points), and Tobias Langhoff’s CHIP-8 guide (45 points).

Not yet checked: Bran’s Kernel Development Tutorial, James Molloy’s kernel tutorials, Harvard’s OS/161, Stanford’s Pintos, Lions’ Commentary on UNIX, Tanenbaum’s MINIX books, Hypervisor in 1,000 Lines.

Method

  • Candidates came from the 212 OS-tagged stories in the 4,140-story pull, plus an OS topic pull with 44 terms: 435 candidates in all (phase1-stories/data/os_candidates.json). Bare “kernel” and “linux” were avoided as release-news noise; “bare metal” and “system calls” still brought in cloud and performance stories, which were skipped by hand.
  • Selection. 46 resources had receipts pulled; 23 are used here, chosen by hand for followability and sequence. Points were then totalled across every submission of each URL.
  • Filters. Gustavo Duarte’s site also hosts essays on other subjects, so only his internals articles count (a title filter on boot, memory, kernel, CPU and related words). The MIT points include the course pages from 6.828 through 6.1810 and the xv6 pages, which HN submitted separately over the years.
  • Quotes come from the top five top-level comments of the two best-scoring threads per resource, in HN’s ranked order via the Firebase API. Some quotes are trimmed with ”…”; links go to the full comment. Every ID and quote is checked with phase1-stories/scripts/check_track.py.
  • Costs and status were checked on 2026-11-08 on each resource’s own page: OSTEP’s print and PDF prices, the 6.1810 2025 lab list and the Fall 2026 notice, the LKMPG update date, the Linux Insides README, OS in 1,000 Lines’ licence, and the Philipp Oppermann post list. All other resources are free web pages or repositories. Time estimates are editorial, not measured.
  • Emulators. The go-further emulator steps come from a separate emulator pull with 35 terms: 191 candidates (phase1-stories/data/emulators_candidates.json), 16 checked. Emulator 101 returned HTTP 403 to our checker on 2026-11-08 and was left out. Writing a RISC-V Emulator in Rust’s published pages and its companion repository’s ten steps were checked the same day.
  • Data: tracks/os/receipts.json (resources used) and candidates_receipts.json (all 46 checked).