d26675708e
L1: Add make qemu-ram target — copies disk image to host tmpfs before
QEMU boots, eliminating host disk I/O during OS runtime.
Usage: make qemu-ram CONFIG_NAME=redbear-full QEMU_MEM=12288
L2: Create local/recipes/AGENTS.md — comprehensive catalog of all 165
custom recipes across 15 categories with descriptions.
L3: CollisionTracker already fully implemented and wired into installer
(recipes/core/installer/source/src/collision.rs, 267 lines).
L4: Add scripts/validate-collision-log.sh to make validate target —
scans build logs for [COLLISION-ERROR]/[COLLISION-WARN] markers
from the runtime CollisionTracker.
55 lines
1.5 KiB
Bash
Executable File
55 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# qemu-ram.sh — Boot Red Bear OS from RAM-disk (tmpfs)
|
|
#
|
|
# Copies the disk image into tmpfs before launching QEMU, eliminating
|
|
# all host disk I/O during OS runtime.
|
|
#
|
|
# Usage: invoked by `make qemu-ram` — not intended for direct use.
|
|
#
|
|
# Arguments:
|
|
# $1 QEMU binary (e.g. qemu-system-x86_64)
|
|
# $2 Disk image path (harddrive.img or live ISO)
|
|
# $3 QEMU flags (space-separated)
|
|
# $4 RAM directory (tmpfs mount point)
|
|
|
|
set -euo pipefail
|
|
|
|
QEMU_BIN="${1:?Usage: qemu-ram.sh <qemu-bin> <disk> <flags> <ramdir>}"
|
|
DISK="${2:?disk image path required}"
|
|
QEMU_FLAGS="${3:?QEMU flags required}"
|
|
RAMDIR="${4:?RAM directory required}"
|
|
|
|
if [ ! -f "$DISK" ]; then
|
|
echo "ERROR: disk image not found: $DISK" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cleanup() {
|
|
echo "Red Bear: cleaning up RAM-disk..."
|
|
if mountpoint -q "$RAMDIR" 2>/dev/null; then
|
|
umount "$RAMDIR" 2>/dev/null || true
|
|
fi
|
|
rmdir "$RAMDIR" 2>/dev/null || true
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
# Size the tmpfs: image size + 512 MiB overhead, minimum 1 GiB
|
|
img_mb=$(du -m "$DISK" | cut -f1)
|
|
tmpfs_mb=$((img_mb + 512))
|
|
[ "$tmpfs_mb" -lt 1024 ] && tmpfs_mb=1024
|
|
|
|
echo "Red Bear: preparing RAM-disk boot..."
|
|
mkdir -p "$RAMDIR"
|
|
|
|
if ! mountpoint -q "$RAMDIR" 2>/dev/null; then
|
|
mount -t tmpfs -o "size=${tmpfs_mb}m" tmpfs "$RAMDIR"
|
|
fi
|
|
|
|
echo "Red Bear: copying $DISK to RAM ($(du -h "$DISK" | cut -f1))..."
|
|
cp "$DISK" "$RAMDIR/disk.img"
|
|
|
|
ram_flags="${QEMU_FLAGS//$DISK/$RAMDIR/disk.img}"
|
|
|
|
echo "Red Bear: booting from RAM-disk..."
|
|
exec "$QEMU_BIN" $ram_flags
|