Skip to main content

Introduction to Creating Your Own OS with Ubuntu

This article is tips for creating HariboteOS.

My HariboteOS

System Setup

  • OS: Ubuntu 18.04

Tools Used

Binary editor

  • hexedit
sudo apt install hexedit
  • ghex
sudo apt install ghex

Assembler

  • nasm
sudo apt install nasm
nasm input.asm -o output (-l output.lst)

C Compiler

  • gcc
gcc -march=i486 -m32 -fno-pie -nostdlib -T [linkerfile] -g *.c *.o -o bootpack.bin

Make OS Image

You can merge asmhead.bin and bootpack.bin by using cat to connect them as text.

cat asmhead.bin bootpack.bin > os.sys

Use mtools to export the OS image.

mformat -f 1440 -C -B ipl.bin -i os.img ::
mcopy -i os.img os.sys ::

The meaning of the options in mtools is as follows.

OptionsDescriptions
-fFilesize
-CCreate MS-MOS file system
-BBoot sector

Emulator

I used QEMU and VirtualBox as emulators. Since there was a problem that QEMU did not work well, I used VirtualBox after I faced the problem.

When using QEMU, you can boot OS with the following command. -fda means image uses floppy disk format.

qemu-system-i386 -fda os.img