ScottOS is a minimalist operating system written in Rust that aims to be fully POSIX-compliant while maintaining simplicity and clarity in its design. This OS is built from scratch using modern systems programming practices and leverages Rust's memory safety features to prevent common OS vulnerabilities.
- Memory Management: Virtual memory with paging support
- Process Management: Preemptive multitasking with round-robin scheduling
- Interrupt Handling: Complete interrupt descriptor table with hardware interrupt support
- File System: In-memory file system with POSIX-like directory structure
- System Calls: POSIX-compliant system call interface
- Async Tasks: Cooperative multitasking for kernel tasks
- Standard system calls (read, write, open, close, etc.)
- Process management (fork, exec, wait, exit)
- File operations and directory management
- Standard error codes and return values
- UNIX-like file system hierarchy
- VGA text mode display
- PS/2 keyboard input
- Serial communication (for debugging)
- Timer interrupts for preemptive scheduling
- x86_64 architecture
- Paging: 4-level page table implementation
- Heap Allocation: Linked list allocator for dynamic memory
- Virtual Memory: Complete virtual address space management
- Frame Allocation: Physical frame allocator from bootloader memory map
- Scheduler: Round-robin scheduling algorithm
- Process Control Blocks: Full process state management
- Context Switching: Register save/restore for process switches
- Process Hierarchy: Parent-child process relationships
- In-Memory FS: Simple but complete file system implementation
- POSIX Structure: Standard directories (/bin, /etc, /home, etc.)
- File Descriptors: Standard file descriptor management
- Metadata: Complete file metadata with permissions and timestamps
- IDT: Complete interrupt descriptor table
- Exception Handlers: CPU exception handling (page faults, double faults, etc.)
- Hardware Interrupts: Timer and keyboard interrupt handling
- PIC Management: Programmable interrupt controller configuration
Before you can build and run ScottOS, you need to install the following components:
# Install rustup if you haven't already
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Restart your shell or run:
source ~/.cargo/env
# Install and set nightly as default for this project
rustup toolchain install nightly
rustup default nightly
# Verify installation
rustc --version
# Should show something like: rustc 1.89.0-nightly
# Add rust source code (required for building core library from source)
rustup component add rust-src
# Add LLVM tools (required for linking)
rustup component add llvm-tools-preview
# Verify components are installed
rustup component list --installed
# Install the bootimage tool for creating bootable disk images
cargo install bootimage
# Verify installation
cargo bootimage --version
# Should show: bootimage 0.10.3 (or similar)
# On macOS:
brew install qemu
# On Ubuntu/Debian:
sudo apt update
sudo apt install qemu-system-x86
# On Arch Linux:
sudo pacman -S qemu
# On Windows:
# Download and install QEMU from https://www.qemu.org/download/
# Verify installation
qemu-system-x86_64 --version
Open a new terminal window and follow these steps:
# Navigate to the project directory
cd /path/to/scottos
# Verify you're in the right directory
ls -la
# You should see Cargo.toml, src/, x86_64-scottos.json, etc.
# Clean any previous build artifacts
cargo clean
# This removes the target/ directory and ensures a fresh build
# Build the ScottOS kernel
cargo build
# You should see output like:
# Compiling scottos v0.1.0 (/path/to/scottos)
# Finished `dev` profile [unoptimized + debuginfo] target(s) in X.XXs
# Create a bootable disk image
cargo bootimage
# You should see output like:
# Building kernel
# Finished `dev` profile [optimized + debuginfo] target(s) in X.XXs
# Building bootloader
# Compiling bootloader v0.9.31
# Finished `release` profile [optimized + debuginfo] target(s) in X.XXs
# Created bootimage for `scottos` at `/path/to/target/x86_64-scottos/debug/bootimage-scottos.bin`
# Method 1: Use cargo run (easiest)
cargo run
# Method 2: Run QEMU directly with more control
qemu-system-x86_64 -drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin
# Method 3: Run with additional QEMU options (debugging)
qemu-system-x86_64 \
-drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin \
-serial stdio \
-display curses
When ScottOS boots successfully, you should see output similar to:
ScottOS v0.1.0
Initializing kernel...
GDT initialized
Interrupts initialized
Memory management initialized
File system initialized
Process scheduler initialized
ScottOS initialization complete!
System ready for operation
Async task running!
- Type on your keyboard - characters should appear on screen
- The async keyboard system processes input asynchronously
- Various POSIX system calls are stubbed out for future implementation
# Run the kernel test suite
cargo test
# This will run tests in QEMU and exit automatically
Issue: can't find crate for 'core'
# Solution: Ensure rust-src is installed
rustup component add rust-src
Issue: rust-lld not found
# Solution: Install LLVM tools
rustup component add llvm-tools-preview
Issue: bootimage not found
# Solution: Install bootimage tool
cargo install bootimage
Issue: QEMU not starting or black screen
# Solution 1: Try with serial output
qemu-system-x86_64 \
-drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin \
-serial stdio
# Solution 2: Enable VGA text mode
qemu-system-x86_64 \
-drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin \
-vga std
Issue: Build warnings about unused code
# These are normal for a development OS - the code is ready for future features
# You can ignore warnings or build with:
cargo build --quiet
# 1. Make code changes
# 2. Build and run in one command
cargo run
# 3. Or for just building without running
cargo build
# 4. Run tests
cargo test
# Enable serial output for debugging
cargo run -- -serial stdio
# Build in release mode (faster but less debug info)
cargo build --release
cargo bootimage --release
# View build artifacts
ls -la target/x86_64-scottos/debug/
# Run with custom memory size
qemu-system-x86_64 \
-drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin \
-m 512M
# Enable KVM acceleration (Linux only)
qemu-system-x86_64 \
-enable-kvm \
-drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin
# Run in background
qemu-system-x86_64 \
-drive format=raw,file=target/x86_64-scottos/debug/bootimage-scottos.bin \
-nographic \
-serial stdio &
# Remove all build artifacts
cargo clean
# Remove bootimage cache
rm -rf ~/.cargo/registry/cache/
# Full clean rebuild
cargo clean && cargo build && cargo bootimage && cargo run
Once you have ScottOS running:
- Explore the code: Check out the modular architecture in
src/
- Add features: Implement additional system calls or device drivers
- Test thoroughly: Use
cargo test
to run the test suite - Experiment: Try modifying the kernel and see the results
Remember: Press Ctrl+C
in the terminal to stop QEMU and return to your shell.
src/
├── main.rs # Kernel entry point and initialization
├── lib.rs # Library exports and common functions
├── vga_buffer.rs # VGA text mode display driver
├── serial.rs # Serial communication for debugging
├── gdt.rs # Global Descriptor Table setup
├── interrupts.rs # Interrupt handling and IDT
├── memory.rs # Memory management and paging
├── allocator.rs # Heap allocator implementation
├── syscall.rs # System call interface
├── fs.rs # File system implementation
├── process.rs # Process management and scheduling
├── keyboard.rs # Keyboard input handling
└── task/ # Async task system
├── mod.rs # Task definitions
├── executor.rs # Task executor
└── keyboard.rs # Async keyboard processing
ScottOS implements standard POSIX system calls:
fork()
- Create child processexec()
- Execute programexit()
- Terminate processwait()
- Wait for child processgetpid()
- Get process ID
open()
- Open fileclose()
- Close fileread()
- Read from filewrite()
- Write to filelseek()
- Seek in file
mkdir()
- Create directoryrmdir()
- Remove directoryreaddir()
- Read directory contents
uname()
- Get system informationstat()
- Get file statusaccess()
- Check file access permissions
ScottOS leverages Rust's ownership system and borrow checker to prevent:
- Buffer overflows
- Use-after-free vulnerabilities
- Double-free errors
- Memory leaks
- Race conditions
The system is designed with clear separation of concerns:
- Each module has a specific responsibility
- Well-defined interfaces between components
- Minimal coupling between subsystems
- Comprehensive error handling
ScottOS aims for full POSIX compliance to ensure:
- Compatibility with standard UNIX tools
- Familiar programming interface
- Standard behavior and semantics
- Portability of applications
This is an educational project demonstrating OS development principles. Key areas for contribution:
- Extended System Calls: Implement more POSIX system calls
- Device Drivers: Add support for more hardware devices
- File Systems: Implement persistent file system formats
- Networking: Add TCP/IP stack and network drivers
- User Space: Develop shell and basic utilities
- Complete system call implementation
- Add more device drivers (mouse, disk)
- Implement persistent file system
- Add shell and basic utilities
- SMP (Symmetric Multiprocessing) support
- Advanced memory management (COW, swapping)
- Network stack implementation
- Graphics support
- Package management system
This project is educational and demonstrates OS development concepts. Feel free to use and modify for learning purposes.
ScottOS - A minimalist, educational operating system showcasing modern systems programming with Rust.