To develop the basic low level operating system, we need following
- Virtual Machine
- Clean Debian OS
- KDE Desktop Environment
You need to have basic knowledge on
- Programming in C
- x86_64 Assembly Programming
- Linux Basic Commands
After getting all this, lets start building the Operating System using Kernel
- Open the Terminal
- Type lsblk command
- It will display sdb. Its actually a Hard Drive
- Change the user to root by typing the command sudo su
- Type cfdisk /dev/sdb
- It will open Hard drive partition table
- Click on [ New ] and hit enter
- Hit Enter again so that it will allocate default size
- Click on [ Primary ] and hit enter
- Click on [ Bootable ] and hit enter
- And then click on [ Write ] and type yes and hit enter
- Finally, click on [ Quit ] to exit
- Run lsblk command again, then we can see that new partition has been created
- This is how we can create a new Bootable hard drive partition to test our OS
- Type mkfs.ext4 /dev/sdb1
- Go to the folder /mnt by typing cd /mnt
- Create a New Folder by typing mkdir folder_name. That will be Name of your OS.
- Mount Your Folder using mount /dev/sdb1 folder_name
- Now, get into the OS by typing cd folder_name
- Remove all the things inside the folder by typing rm -rvf *
- Create following folders that will be used for OS Creation by typing the command given below
- mkdir -p ./{etc,lib,lib64,boot,bin,sbin,var,dev,proc,sys,run,tmp,src}
- After creating the folders, set mknod by typing following commands
- mknod -m 600 ./dev/console c 5 1
mknod -m 666 ./dev/null c 1 3 - Go to boot folder by typing cd boot
- Now, let's copy the Kernel File and Initial Ram Disk from /boot folder
- cp /bootvmlinuz-4.19.0-10-amd64 .
cp /boot/initrd.img-4.19.0-10.amd64 - Now, let's install some dependences using following command
- grub-install /dev/sdb --skip-fs-probe --boot-directory=/mnt/folder_name/boot
- It will install grub folder. Now, let's start coding part
- Make sure you are in grub directory created previously
- Create a new file grub.cfg using any editor. My suggestion is to go with VI
- The code is at [ grub.cfg ]. For Explanation, go to [ Documentation/grub/readme.md ]
- After that, Go to src folder created in folder_name or simple type cd ../../src
- Create folders [ lib ] and [ init ] using mkdir -p ./{lib,init}
- Go to lib folder and create [ start.S ]
- Get back to src folder and go to init folder and create [ init.c ]