Build your own OS (Part 1)

Sahan Rashmika Silva
3 min readOct 1, 2022

--

Have you ever thought to make an your own operating system ? if yes ,this is the complete journey for how to implement you own operating sysem.I prefer to share the progress and the step by step guidance once a week.So I request to join with me till the end of this article series and be a proud owner of your own operating system.

So, developing an OS is not easy task.It’s much complicated and difficult process.I think it’s much intersting through my step by step guidance.

1- Installing a virtual machine

We can make an OS much easier by using virtual machines rather than physical computers. Because , executing our operating system using virtual machine much faster than physical computer.

A virtual machine is the emulation of a computer system, which is based on computer architecture and provides the functionality of a physical computer. Their implementations may involve specialized hardware, software, or a combination of the two.

We will use Oracle VM VirtualBox as our virtual machine for this project.

2- Installing and Setting up a host operating system.

We use Ubuntu as a host operating system in this project. If you haven’t ubuntu download & install it.Then we should install following packages using apt-get.

ubuntu on virtual box

we use C programming language with the GCC compiler oto develop our OS.We selected C as building an operating system requires precise control over generated code as well as direct memory access.For writing assembly code, we’ll use NASM as the assembler.

3- Gettig familiar with creating files on Ubuntu

The touch command in Ubuntu is simply used to create empty files.

4- Booting Process.

Booting an OS is consist of three main steps such as BIOS,Bootloader and OS.Each one is more powerful than the one before it, with the operating system being the final and most powerful one.

BIOS

This application is typically kept on a read-only memory chip on the PC’s motherboard.Nowadays, BIOS mainly performs some early diagnostics(power-on-self-test) and then transfers control to the bootloader.In your computer,it will start a small software that follows the basic input output system(BIOS) standard when it starts.

Bootloader

Then the BIOS programme handover the control of PC to bootloader.The bootoader’s task is to transfer control to OS. Sometimes the bootloader divided into two parts due to hardware limitations and backward compatibility.The first part of bootloader transfers control of the PC to the OS.

A bootloader requires a lot of low-level code to interact with the BIOS.As a result, we will usee an existing bootloader called : GNU (General Unified Bootloader) .

The operating system can be constructed using GRUB as an ‘.ELF’ executable, which we will loaded in to the correct memory location by GRUB.

Operating System

GRUB will handover the control to OS by jumping to a memory location.GRUB will search for a magic number before the leap to guarantee that it is indedd jumping to an OS and not some arbitary code.This magic number is a requirment of the multiboot protocol, to which GRUB conforms.Once GRUB has completed the transition , the operaing system has complete control of the computer.

5- Compiling the OS.

In this stage, we gonna compiling the OS.

--

--