diff --git a/qemu/Image b/qemu/Image new file mode 100644 index 0000000..bed554d Binary files /dev/null and b/qemu/Image differ diff --git a/qemu/README.md b/qemu/README.md new file mode 100644 index 0000000..927d81f --- /dev/null +++ b/qemu/README.md @@ -0,0 +1,53 @@ +# Nova OS — QEMU + +Boot Nova OS under QEMU emulation (ARM64 virt machine). + +## Quick Start + +```bash +# Install QEMU +sudo apt install qemu-system-arm + +# Add yourself to kvm group (for hardware acceleration) +sudo usermod -a -G kvm $USER +# Log out and back in for this to take effect + +# Run +./run.sh +``` + +## What You Get + +- ARM64 virtual machine with 4 Cortex-A76 cores, 2GB RAM +- VirtIO block storage (raw image) +- VirtIO networking with port forward: `localhost:2222` → guest SSH port 22 +- Serial console in your terminal + +## SSH Access + +Once booted: +```bash +ssh -p 2222 root@localhost +``` +Password: `nova` (forced change on first login) + +## Configuration + +Override defaults via environment variables: + +| Variable | Default | Description | +|----------|---------|-------------| +| `NOVA_IMAGE` | `../nova-os-4.3.1.img` | Path to raw disk image | +| `NOVA_CPU` | `cortex-a76` | CPU model | +| `NOVA_SMP` | `4` | Number of CPU cores | +| `NOVA_MEM` | `2048` | RAM in MB | +| `NOVA_SSH_PORT` | `2222` | Host port for SSH forwarding | + +## Acceleration + +- **KVM** (near-native): auto-detected if `/dev/kvm` is writable +- **TCG** (emulation): fallback — works but ~50-90x slower + +## Quit + +Press `Ctrl-A` then `X` to exit QEMU. diff --git a/qemu/run.sh b/qemu/run.sh new file mode 100755 index 0000000..24c3ea6 --- /dev/null +++ b/qemu/run.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# Nova OS — QEMU Launcher (ARM64 virt) +# Boots the Nova OS raw image under QEMU emulation. +# +# Usage: +# ./run.sh [image_path] +# +# Default image: ../nova-os-4.3.1.img (or set NOVA_IMAGE env var) +# +# After boot: +# ssh -p 2222 root@localhost (password: nova, forced change) +# +# Requirements: +# qemu-system-aarch64 (Debian: apt install qemu-system-arm) + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +BUILD_DIR="${SCRIPT_DIR}/../build" + +# ── Configuration ────────────────────────────────────────────── +IMAGE="${NOVA_IMAGE:-${SCRIPT_DIR}/../nova-os-4.3.1.img}" + +# Prefer local kernel, fall back to build tree +if [ -f "${SCRIPT_DIR}/Image" ]; then + KERNEL="${SCRIPT_DIR}/Image" +elif [ -f "${BUILD_DIR}/linux-7.0.12/arch/arm64/boot/Image" ]; then + KERNEL="${BUILD_DIR}/linux-7.0.12/arch/arm64/boot/Image" +else + echo "ERROR: kernel Image not found" >&2 + exit 1 +fi + +CPU="${NOVA_CPU:-cortex-a76}" +SMP="${NOVA_SMP:-4}" +MEM="${NOVA_MEM:-2048}" +SSH_PORT="${NOVA_SSH_PORT:-2222}" + +# ── Validate ─────────────────────────────────────────────────── +for f in "$IMAGE" "$KERNEL"; do + if [ ! -f "$f" ]; then + echo "ERROR: not found — $f" >&2 + exit 1 + fi +done + +# ── Acceleration ────────────────────────────────────────────── +if [ -w /dev/kvm ]; then + ACCEL="kvm" + echo " Accel: KVM (hardware)" +else + ACCEL="tcg" + echo " Accel: TCG (emulation — slow)" +fi +echo "═══════════════════════════════════════════" +echo " Nova OS — QEMU (ARM64 virt)" +echo " CPU: $CPU" +echo " Cores: $SMP" +echo " RAM: ${MEM}MB" +echo " Accel: ${ACCEL}" +echo " SSH: localhost:$SSH_PORT → guest:22" +echo " Console: this terminal (Ctrl-A X to quit)" +echo "═══════════════════════════════════════════" +echo "" + +exec qemu-system-aarch64 \ + -M virt,accel=${ACCEL} \ + -cpu "$CPU" \ + -smp "$SMP" \ + -m "$MEM" \ + \ + -kernel "$KERNEL" \ + -append "console=ttyAMA0 root=/dev/vda2 rootwait rw quiet loglevel=3" \ + \ + -drive file="$IMAGE",format=raw,if=virtio \ + \ + -netdev user,id=net0,hostfwd=tcp::${SSH_PORT}-:22 \ + -device virtio-net-device,netdev=net0 \ + \ + -nographic