mirror of
https://github.com/johndoe6345789/SparkOS.git
synced 2026-04-24 13:34:56 +00:00
- Add DNS configuration with fallback servers (8.8.8.8, 1.1.1.1, etc.) - Create /etc/network/interfaces for wired DHCP networking - Add init-network script to bring up wired interface on boot - Update init.c to call network initialization - Update documentation to include sudo in default packages - Update README with network testing and binary installation guide - Update ARCHITECTURE.md with networking strategy details Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
5.2 KiB
5.2 KiB
SparkOS Architecture
Overview
SparkOS is designed as a minimal Linux distribution with a custom init system and a modular architecture that allows for future expansion.
System Components
1. Init System (/sbin/init)
The init system is the first process started by the kernel (PID 1). It is responsible for:
- Mounting filesystems: proc, sys, dev, tmp
- Network initialization: Bringing up wired networking via DHCP
- Process management: Spawning and respawning the shell
- Signal handling: Reaping zombie processes
- System initialization: Setting up the initial environment
Implementation: src/init.c
- Written in C for minimal overhead
- Statically linked for independence
- ~100 lines of clean, well-documented code
2. Root Filesystem
Follows the Filesystem Hierarchy Standard (FHS):
/
├── bin/ Essential user binaries (busybox with symlinks)
├── sbin/ System binaries (init, mount, etc.)
├── etc/ System configuration files
├── proc/ Kernel process information (virtual)
├── sys/ Kernel system information (virtual)
├── dev/ Device files (virtual)
├── tmp/ Temporary files
├── usr/
│ ├── bin/ Non-essential user binaries
│ ├── sbin/ Non-essential system binaries
│ ├── lib/ Libraries for /usr/bin and /usr/sbin
│ └── lib64/ 64-bit libraries
├── var/ Variable data (logs, caches)
├── root/ Root user home directory
└── home/ User home directories
3. Build System
Makefile: Main build orchestration
make init: Compile init systemmake install: Install init to rootfsmake image: Create bootable image (requires root)make clean: Clean build artifacts
Scripts:
scripts/build.sh: Quick build for developmentscripts/setup_rootfs.sh: Create rootfs structurescripts/create_image.sh: Create dd-able disk image
4. Boot Process
Hardware Power-On
↓
BIOS/UEFI
↓
Bootloader (syslinux)
↓
Linux Kernel (vmlinuz)
↓
Init System (/sbin/init) [PID 1]
↓
Mount filesystems
↓
Initialize network (/sbin/init-network)
↓
Spawn busybox sh shell
↓
User interaction
Design Decisions
Why Custom Init?
- Simplicity: No dependencies, easy to understand
- Control: Full control over boot process
- Size: Minimal footprint (<1MB statically linked)
- Learning: Educational value for OS development
Why Static Linking?
- Independence: No library dependencies
- Portability: Works on any Linux system
- Reliability: No missing library issues
Why Busybox?
- Minimal: Single binary provides dozens of utilities
- Small footprint: Typically <1MB for full feature set
- Efficient: Less memory and storage overhead than full GNU coreutils
- Standard: De facto standard for embedded Linux systems
- Networking: Includes DHCP client (udhcpc), ping, wget, and network tools
Networking Strategy
SparkOS uses a two-phase networking approach:
Phase 1: Bootstrap (Wired Only)
- Wired networking configured via DHCP
- Automatic interface detection (eth0, enp0s3, etc.)
- DNS fallback to public servers (8.8.8.8, 1.1.1.1)
- Enables git clone to install spark CLI
Phase 2: Full Configuration (via spark CLI)
- WiFi configuration
- Advanced networking features
- Custom DNS settings
- Network profiles
Future Architecture
Planned Components
-
Qt6/QML GUI
- Full-screen Wayland application
- Android-like interface design
- Desktop-oriented workflow
-
Wayland Compositor
- Custom compositor for SparkOS
- Minimal resource usage
- Touch and mouse support
-
Spark CLI Tools (C++)
- System management utilities
- Package management
- Network configuration (WiFi, VPN, etc.)
- GUI launcher
-
Bootstrap Utilities (Included)
- Git for cloning spark CLI
- Sudo for proper privilege elevation
- Busybox for core system utilities and networking
Security Considerations
- Static binaries reduce attack surface
- Minimal running processes
- Root filesystem can be read-only
- Future: sudo for privilege escalation
- Future: SELinux/AppArmor integration
Performance
- Fast boot time (seconds, not minutes)
- Low memory footprint (~50MB base system with busybox)
- No unnecessary background services
- Efficient init system
Portability
- AMD64 architecture (x86_64)
- dd-able disk images
- USB flash drive ready
- Future: ARM64 support
Extension Points
The architecture is designed for easy extension:
- Init system: Can be enhanced with service management
- Filesystem: Can add more mount points and partitions
- Boot process: Can integrate other bootloaders
- GUI: Clean separation allows GUI to be optional
Development Workflow
- Modify source code in
src/ - Build with
make init - Test init in isolation
- Install to
rootfs/withmake install - Create test image with
sudo make image - Test on real hardware or VM
References
- Linux Kernel Documentation
- Filesystem Hierarchy Standard (FHS)
- POSIX Standards
- Qt6 Documentation
- Wayland Protocol Specification