Getting Started on Building an Operating System using Vagrant
(added credits)
Step 1:
If you don't have vagrant installed,
then follow first 10 steps in
README.
Step 2:
Using Git...
$cd "/d/vagrant"
$mkdir basic-os && cd basic-os
$vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
--- this is Ubuntu lucid32 image
It will take some hours to complete the installation...
Step 3:
After installation...
Open any code editor...
Copy-Paste this file into the editor and save it as Vagrantfile
without any file extension in basic-os
directory.
Step 4:
$vagrant up
It will take some minutes to complete (since it's first time to boot up lucid32)...
Step 5:
$cd "/d/[someother path]"
$git clone https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System.git
The src
folder consists of kernel
, disk-booting
and user area
.
Copy all files in src
folder and paste it in basic-os
directory.
Step 6:
$vagrant ssh
$cd /vagrant
$make all
-- it can't run because the $make rundisk-image file
in basic-os/sdk
is corrupted.
Step 7:
Guess what? We successfully learnt how an operating system is made and built
...
Keep that cloned-repo
.
In that cloned-repo
itself, the chapters will help in understanding the internal-build
.
Now, delete those basic-os directory files (except Vagrantfile
and .vagrant folder
)
Keep lucid32
for future use...
LOL
$vagrant halt
$vagrant up
$vagrant provision
Adding Try-Attempts:-
After Step 5
,
Goto basic-os/sdk
directory, Delete the c disk image, diskimage.sh, qemu.sh
Create own disk image inorder to avoid file corruption.
Make sure that Git bash
is running in admin mode
.
$vagrant ssh
$cd /vagrant
We will create disk-image inside sdk
directory.
$cd sdk
$qemu-img create c.img 2M
$fdisk ./c.img << EOF
x
c
4
h
16
s
63
r
n
p
1
1
4
a
1
w
$fdisk -l -u ./c.img
--- Got Permission denied $losetup -o 32256 /dev/loop1 ./c.img
$mke2fs /dev/loop1
--- Got Permission denied
--- Got Permission denied $mount /dev/loop1 /mnt/
$cp -R bootdisk/* /mnt/
--- Got Permission denied
--- Got Permission denied $umount /mnt/
If permission does not get denied, then a successfully disk image will be ready to run.
Installing GRUB
on the disk:
$grub --device-map=/dev/null << EOF
>>device (hd0) ./c.img
>>geometry (hd0) 4 16 63
>>root (hd0,0)
>>setup (hd0)
>>quit
>>EOF
--- Got Permission denied $losetup -d /dev/loop1
If permission is not denied, then GRUB will successfully boot.
$make run
The OS will run if it never received permission-denied in any commands.
~$exit
$vagrant halt
If failed, Go to Step 7
.