Wednesday, January 12, 2011

Making your own Operating System - Getting Started

This is my first actual technical blog article. So as a starter I'm going to guide you all through a tutorial on making your own Operating System. (Yeah..I'm not's going to be an up and running OS)

This was an assignment that was given to us at the University. So just thought of sharing it with you all, because it was one of the assignments i enjoyed doing, and this might help someone in the future...

Assuming that you have a Linux distro installed [I'm using Ubuntu during this walk through.] and that you know how to work yourself around a little bit..(If you don't, feel free to ask, I'd be happy to help you.) lets take the first step...

The first step would be to  follow this tutorial by Mr. Asiri Rathnayake provides the necessary initialization. 
Hacking JOSH – Operating System Tutorial 

After confirming that you can successfully boot from the image in your pen drive, lets do some modding.

 Tip#1: During the process of modifying the OS, you'll have to enter some code and to restart the computer with JOSH OS to try out your code. Instead of having to restart your computer all the time, you can easilly use a virtual machine. To do that you need a bootable image file. Here's how you can get one for yourself.
Open the terminal and create a directory for floppy drive,
sudo mkdir /media/floppy0
Then you have to create an image of the pen drive which you modified using the tutorial provided above...
sudo dd if=/dev/sdb of=/JOSH.img
mount that image in the drive,
sudo mount -o loop -t vfat /josh.img /media/floppy0
Then give that floppy drive as the boot device for your virtual machine.
I'd suggest Virtual box or the qemu as the virtual machine but you can't use them both. qemu is faster and the Virtual box is more user friendly. Both are free.. :)
Install qemu using this command,
sudo apt-get install qemu
Then you can mount your image using this command,
qemu -fda /JOSH.img
If you decided to use VirtualBox then it's fairly easy, because it has a wizard to help  you with it. Here's a little help.
Open VirtualBox and create a new Machine. Set the settings as you desire.
Operating system - Other
Version - Other/Unknown
Base Memory Size (RAM Size) = 64MB (default)
Remove the tick from the "Boot Hard Disk" option
Next => Continue => Finish

Select the settings option of the created machine and go to Storage
The Floppy Controller will be that "Empty" label and select the Floppy device and click the button next to it..It will pop up the Virtual Media Manager window. Under that window select Add=> and locate your JOSH.img file.
Press Start and try out. 

Go on, knock your selves out and try to boot from the JOSH.img.
Type this in the shell, 

    ver - it will print the current version.

Try to open and read the kernel.asm file  and do some changes. Next time we meet here, I'll tell you how to show the hardware information of the computer using our JOSH OS.
Don't be afraid to work around in a virtual machine, after all it's virtual. ;)

Have fun!

PS: Read the Next Step to create your own Operating System here.