AeroOS / scripts /run_vbox.sh
Jaswanth-2008's picture
Upload AeroOS complete Rust source code
dcbeeb2 verified
Raw History Blame Contribute Delete
2.94 kB
#!/usr/bin/env bash
set -e
# ==============================================================================
# AeroOS VirtualBox Boot Script for macOS (Apple Silicon / Intel)
# ==============================================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${PROJECT_ROOT}"
VM_NAME="AeroOS-Desktop"
RAW_IMG="${PROJECT_ROOT}/target/x86_64-unknown-none/debug/aero-kernel.bios.img"
VDI_PATH="${PROJECT_ROOT}/target/aero-os.vdi"
echo "============================================================"
echo " AeroOS VirtualBox Automated Launcher "
echo "============================================================"
# Check if VBoxManage is installed
if ! command -v VBoxManage &>/dev/null; then
echo "[!] Error: 'VBoxManage' not found in PATH."
exit 1
fi
# Always compile latest kernel and generate bootable images
echo "[*] Compiling latest AeroOS kernel..."
cargo build --package aero-kernel --target x86_64-unknown-none
cargo run --package aero-runner -- target/x86_64-unknown-none/debug/aero-kernel
# Clean up any existing VM with the same name
if VBoxManage list vms | grep -q "\"${VM_NAME}\""; then
echo "[*] Resetting previous VM instance..."
VBoxManage controlvm "${VM_NAME}" poweroff 2>/dev/null || true
sleep 2
VBoxManage unregistervm "${VM_NAME}" --delete 2>/dev/null || true
fi
rm -rf "${HOME}/VirtualBox VMs/${VM_NAME}" 2>/dev/null || true
# Convert raw disk to native VirtualBox VDI
echo "[*] Converting raw image to VirtualBox VDI format..."
rm -f "${VDI_PATH}"
rm -f "${PROJECT_ROOT}/target/aeroos_serial.log"
VBoxManage convertfromraw "${RAW_IMG}" "${VDI_PATH}" --format VDI
echo "[*] Creating VirtualBox VM: ${VM_NAME}..."
VBoxManage createvm --name "${VM_NAME}" --ostype "Other_64" --register
echo "[*] Configuring VM hardware (2048 MB RAM, 128 MB VRAM, PS/2 input)..."
VBoxManage modifyvm "${VM_NAME}" \
--memory 2048 \
--vram 128 \
--cpus 2 \
--firmware bios \
--boot1 disk \
--mouse ps2 \
--keyboard ps2 \
--audio-driver none \
--nic1 nat \
--nictype1 virtio \
--uart1 0x3F8 4 \
--uart-mode1 file "${PROJECT_ROOT}/target/aeroos_serial.log" \
--uart-type1 16550A
echo "[*] Creating SATA storage controller..."
VBoxManage storagectl "${VM_NAME}" --name "SATA Controller" --add sata --controller IntelAHCI
echo "[*] Attaching AeroOS VDI hard disk (${VDI_PATH})..."
VBoxManage storageattach "${VM_NAME}" \
--storagectl "SATA Controller" \
--port 0 \
--device 0 \
--type hdd \
--medium "${VDI_PATH}"
echo "[+] Starting VirtualBox VM: ${VM_NAME}..."
VBoxManage startvm "${VM_NAME}" --type gui
# Focus VirtualBox window on macOS desktop
sleep 1
osascript -e 'tell application "System Events" to set frontmost of first process whose name contains "VirtualBox" to true' 2>/dev/null || true