https://github.com/dorydev/linuxfromscratch
Simple kernel (will be upgraded later)
https://github.com/dorydev/linuxfromscratch
c grub kernel
Last synced: 8 months ago
JSON representation
Simple kernel (will be upgraded later)
- Host: GitHub
- URL: https://github.com/dorydev/linuxfromscratch
- Owner: dorydev
- Created: 2024-01-14T18:01:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-06T08:43:27.000Z (11 months ago)
- Last Synced: 2025-04-12T05:51:32.611Z (10 months ago)
- Topics: c, grub, kernel
- Language: C
- Homepage:
- Size: 4.19 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🐧 Linux From Scratch
A simple Linux-based kernel written in C and x86_64 assembly.
## 📋 Table of Contents
- [📖 Project Overview](#project-overview)
- [🔧 Prerequisites](#prerequisites)
- [⚙️ How to Compile](#how-to-compile)
- [📝 Compile Assembly and C Files](#compile-assembly-and-c-files)
- [🔗 Link Object Files](#link-object-files)
- [💿 Create ISO File with GRUB](#create-iso-file-with-grub)
- [🚀 Launch in QEMU](#launch-in-qemu)
- [💡 Usage](#usage)
## 📖 Project Overview
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.
## 🔧 Prerequisites
Ensure you have the following tools installed:
- grub
- nasm
- gcc
- xorriso
- qemu
Alternatively, you can use the `build.sh` script to install the dependencies:
```sh
./build.sh
```
## ⚙️ How to Compile
### 📝 Compile Assembly and C Files
Compile the assembly and C files into object files using nasm and gcc:
```sh
nasm -f elf32 boot.s -o boot.o
gcc -m32 -ffreestanding -nostdlib -c kernel.c -o kernel.o
```
### 🔗 Link Object Files
Link the object files to create the kernel binary:
```sh
ld -m elf_i386 -T linker.ld -o kernel.bin boot.o kernel.o
```
### 💿 Create ISO File with GRUB
Create an ISO file using grub:
```sh
grub-mkrescue -o LinuxFromScratch.iso LinuxFromScratch/*
```
### 🚀 Launch in QEMU
Open the project folder in your terminal and type:
```sh
cd LinuxFromScratch
qemu-system-i386 -cdrom LinuxFromScratch.iso
```
Alternatively, you can use the Makefile for compilation:
- To build the kernel binary:
```sh
make
```
- To create a bootable ISO image:
```sh
make iso
```
- To clean up the build files:
```sh
make clean
```
- To rebuild the project:
```sh
make re
```
- To run the kernel directly:
```sh
make run
```
- To run the kernel with GRUB:
```sh
make rungrub
```
## 💡 Usage
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!**