I was making a Linux OS from scratch. I came accross this article, which creates a bare minimum Linux OS which just prints hello world once linux kernel boot.
So my question is , in which space [kernel or user space] such a helloworld program is running ? My conscience says its kernel space, then how do I make it run in user space ?
For people who do not want to read that lengthy article here is what it does in short.
- I formatted my USB flash drive [/dev/sdb on my linux system] with ext4 file format.
- Mounted it to /mnt/mylinux folder.
- Created folders /boot and /bin in it.
- Placed a copy of Linux Kernel [I compiled from github source code.] bzImage in /boot folder
- Installed grub2 in /boot folder of /dev/sdb, and created grub.cfg file to specify my init program.
My init program.
#include <stdio.h>
#include <unistd.h>
int main(void){
while(1){
printf("Hello World\n");
sleep(1);
}
}
My init program is statically compiled and placed in /bin folder.
So when I boot this drive , it starts printing : Hello World
write
at some point, which is a system call