Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Doing your own toy operating system is a great learning experience and I can recommend it to anyone who has the right hacker attitude and a little bit of prerequisite knowledge.

OSdev is a pretty good starting point for basic resources. 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. Do not write your own bootloader code or try to stick to pure asm, you'll get nowhere fast. Use the multiboot protocol so you can easily get booted on emulators and real iron using GRUB2. Note: I assumed you want to work on x86.

In addition to OSdev, the Intel manuals are an excellent resource. They are a pretty nice thing to read even if you don't intend to write an OS. Although reading through them will probably get your OS hacking itch going and you can't stop yourself. That happened to me. The Intel manuals are here: http://www.intel.com/content/www/us/en/processors/architectu... . Volumes 1 and 3a are the most important.

And here are the humble beginnings of my hobby operating system: https://github.com/rikusalminen/danjeros



When I read "Do not write your own bootloader...", I immediately objected until I saw "assumed...x86". In that case, I agree. If you are going to build an OS for ARM or MIPS, you really learn a lot if you make your own bootloader.


Only when you want to run it on real hardware. Most qemu targets can boot straight from a binary blob or an ELF image (the emulator initializes the emulated hardware and then sets the PC to the address where the blob is loaded). Those that can't are easily modifiable to do so.

Also, U-Boot can boot a lot of things this days.

So if I were to build an OS for ARM or MIPS I would:

1) Build it on an emulator that can boot from ELF or a binary blob.

2) When it's time to run on real hardware, try to use U-Boot.

3) If that fails, write my own boot loader.

The moral of the story is: bootloaders are not my kind of fun, so I'll avoid writing them at all costs.


Right, but you've presumably already done it once and thus extracted all pedagogical value from it.


Yes, you're right. For my OS class when I was in school, instead of doing the proposed homework, I convinced the professor to let me do a x86 OS. We were a group of 3. I started doing everything in C with as little as assembly as possible, but the other two decidet to do an all-assembly little monster.

At the end of the course, we had only the boot loader and a little command interpreter, aside from FAT-12 support.

Then, much later, I messed with OS by playing with the code from the Minix Book [1].

Last year I wrote a little emulator for a virtually unknown architecture that can run uClinux on a modern browser (i.e., Chrome)[2].

[1] Operating System Design and Implemenation: http://www.amazon.com/Operating-Systems-Design-Implementatio...

[2] https://github.com/ubercomp/jslm32/


My class-project-turned-hobby-os: https://github.com/tjdetwiler/timix




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: