A simple Linux-based kernel written in C and x86_64 assembly.
This project aims to create a minimal Linux-based operating system from scratch. It involves writing a kernel in C and assembly, setting up a bootloader, and creating an ISO image that can be run in a virtual machine.
Ensure you have the following tools installed:
- grub
- nasm
- gcc
- xorriso
- qemu
Alternatively, you can use the build.sh
script to install the dependencies:
./build.sh
Compile the assembly and C files into object files using nasm and gcc:
nasm -f elf32 boot.s -o boot.o
gcc -m32 -ffreestanding -nostdlib -c kernel.c -o kernel.o
Link the object files to create the kernel binary:
ld -m elf_i386 -T linker.ld -o kernel.bin boot.o kernel.o
Create an ISO file using grub:
grub-mkrescue -o LinuxFromScratch.iso LinuxFromScratch/*
Open the project folder in your terminal and type:
cd LinuxFromScratch
qemu-system-i386 -cdrom LinuxFromScratch.iso
Alternatively, you can use the Makefile for compilation:
- To build the kernel binary:
make
- To create a bootable ISO image:
make iso
- To clean up the build files:
make clean
- To rebuild the project:
make re
- To run the kernel directly:
make run
- To run the kernel with GRUB:
make rungrub
Once the ISO is created and launched in QEMU, the kernel will display "HELLO WORLD" on the screen. This demonstrates the basic functionality of the kernel and its ability to interact with the VGA buffer.
Congratulations, it works!