From 2ebd6f7d76feed9d83a743b168fd148fe0eb8496 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 17 Jan 2026 23:15:33 -0600 Subject: Add multi-disk RAID, SSH config, stripe option, remove colors - Multi-disk RAID support: mirror, stripe, raidz1/2/3 - EFI partitions on all disks for boot redundancy - SSH configuration prompt (default yes) with sshd enabled - Stripe option for max capacity without redundancy - Genesis snapshot with rollback-to-genesis script - NetworkManager added to ISO for WiFi config - Remove color codes for better terminal compatibility - archsetup launcher via curl --- scripts/test-vm.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/test-vm.sh b/scripts/test-vm.sh index 581fa6c..c5ff5e8 100755 --- a/scripts/test-vm.sh +++ b/scripts/test-vm.sh @@ -2,9 +2,10 @@ # test-vm.sh - Test the archzfs ISO in a QEMU virtual machine # # Usage: -# ./test-vm.sh # Create new VM and boot ISO -# ./test-vm.sh --boot-disk # Boot from existing virtual disk (after install) -# ./test-vm.sh --clean # Remove VM disk and start fresh +# ./test-vm.sh # Create new VM and boot ISO (single disk) +# ./test-vm.sh --multi-disk # Create VM with multiple disks for RAID testing +# ./test-vm.sh --boot-disk # Boot from existing virtual disk (after install) +# ./test-vm.sh --clean # Remove VM disks and start fresh set -e @@ -15,9 +16,13 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")" VM_NAME="archzfs-test" VM_DIR="$PROJECT_DIR/vm" VM_DISK="$VM_DIR/$VM_NAME.qcow2" +VM_DISK2="$VM_DIR/$VM_NAME-disk2.qcow2" +VM_DISK3="$VM_DIR/$VM_NAME-disk3.qcow2" VM_DISK_SIZE="50G" VM_RAM="4096" VM_CPUS="4" +MULTI_DISK=false +NUM_DISKS=1 # UEFI firmware (adjust path for your system) OVMF_CODE="/usr/share/edk2/x64/OVMF_CODE.4m.fd" @@ -63,7 +68,7 @@ check_deps() { fi } -# Create VM directory and disk +# Create VM directory and disk(s) setup_vm() { mkdir -p "$VM_DIR" @@ -74,6 +79,23 @@ setup_vm() { info "Using existing disk: $VM_DISK" fi + # Create additional disks for multi-disk mode + if [[ "$MULTI_DISK" == true ]]; then + if [[ ! -f "$VM_DISK2" ]]; then + info "Creating virtual disk 2: $VM_DISK2 ($VM_DISK_SIZE)" + qemu-img create -f qcow2 "$VM_DISK2" "$VM_DISK_SIZE" + else + info "Using existing disk 2: $VM_DISK2" + fi + + if [[ $NUM_DISKS -ge 3 && ! -f "$VM_DISK3" ]]; then + info "Creating virtual disk 3: $VM_DISK3 ($VM_DISK_SIZE)" + qemu-img create -f qcow2 "$VM_DISK3" "$VM_DISK_SIZE" + elif [[ $NUM_DISKS -ge 3 ]]; then + info "Using existing disk 3: $VM_DISK3" + fi + fi + # Copy OVMF vars if needed if [[ ! -f "$OVMF_VARS" ]]; then info "Setting up UEFI variables" @@ -85,6 +107,8 @@ setup_vm() { clean_vm() { warn "Removing VM files..." rm -f "$VM_DISK" + rm -f "$VM_DISK2" + rm -f "$VM_DISK3" rm -f "$OVMF_VARS" info "VM files removed. Ready for fresh install." } @@ -94,21 +118,37 @@ boot_iso() { find_iso setup_vm + local disk_info="$VM_DISK_SIZE" + if [[ "$MULTI_DISK" == true ]]; then + disk_info="$NUM_DISKS x $VM_DISK_SIZE (RAID testing)" + fi + info "Starting VM with ISO..." echo "" echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo " VM: $VM_NAME" echo " RAM: ${VM_RAM}MB | CPUs: $VM_CPUS" - echo " Disk: $VM_DISK_SIZE" + echo " Disks: $disk_info" echo " ISO: $(basename "$ISO_FILE")" echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo "" echo "Tips:" echo " - Press Ctrl+Alt+G to release mouse grab" echo " - Press Ctrl+Alt+F to toggle fullscreen" + echo " - Serial console output appears in this terminal" + echo " - SSH: ssh -p 2222 root@localhost (password: archzfs)" echo " - Run 'install-archzfs' to start installation" echo "" + # Build disk arguments + local disk_args=(-drive "file=$VM_DISK,format=qcow2,if=virtio") + if [[ "$MULTI_DISK" == true ]]; then + disk_args+=(-drive "file=$VM_DISK2,format=qcow2,if=virtio") + if [[ $NUM_DISKS -ge 3 ]]; then + disk_args+=(-drive "file=$VM_DISK3,format=qcow2,if=virtio") + fi + fi + qemu-system-x86_64 \ -name "$VM_NAME" \ -machine q35,accel=kvm \ @@ -117,13 +157,14 @@ boot_iso() { -m "$VM_RAM" \ -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \ -drive if=pflash,format=raw,file="$OVMF_VARS" \ - -drive file="$VM_DISK",format=qcow2,if=virtio \ + "${disk_args[@]}" \ -cdrom "$ISO_FILE" \ -boot d \ -netdev user,id=net0,hostfwd=tcp::2222-:22 \ -device virtio-net-pci,netdev=net0 \ -device virtio-vga-gl \ -display gtk,gl=on \ + -serial mon:stdio \ -audiodev pipewire,id=audio0 \ -device ich9-intel-hda \ -device hda-duplex,audiodev=audio0 \ @@ -139,11 +180,31 @@ boot_disk() { error "No disk found. Run without --boot-disk first to install." fi + # Auto-detect multi-disk setup + if [[ -f "$VM_DISK2" ]]; then + MULTI_DISK=true + if [[ -f "$VM_DISK3" ]]; then + NUM_DISKS=3 + else + NUM_DISKS=2 + fi + fi + info "Booting from installed disk..." echo "" - echo "SSH access: ssh -p 2222 localhost" + echo "SSH access: ssh -p 2222 root@localhost" + echo "Serial console output appears in this terminal" echo "" + # Build disk arguments + local disk_args=(-drive "file=$VM_DISK,format=qcow2,if=virtio") + if [[ "$MULTI_DISK" == true ]]; then + disk_args+=(-drive "file=$VM_DISK2,format=qcow2,if=virtio") + if [[ $NUM_DISKS -ge 3 ]]; then + disk_args+=(-drive "file=$VM_DISK3,format=qcow2,if=virtio") + fi + fi + qemu-system-x86_64 \ -name "$VM_NAME" \ -machine q35,accel=kvm \ @@ -152,12 +213,13 @@ boot_disk() { -m "$VM_RAM" \ -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \ -drive if=pflash,format=raw,file="$OVMF_VARS" \ - -drive file="$VM_DISK",format=qcow2,if=virtio \ + "${disk_args[@]}" \ -boot c \ -netdev user,id=net0,hostfwd=tcp::2222-:22 \ -device virtio-net-pci,netdev=net0 \ -device virtio-vga-gl \ -display gtk,gl=on \ + -serial mon:stdio \ -audiodev pipewire,id=audio0 \ -device ich9-intel-hda \ -device hda-duplex,audiodev=audio0 \ @@ -170,24 +232,36 @@ show_help() { echo "Usage: $0 [OPTIONS]" echo "" echo "Options:" - echo " (none) Create VM and boot from ISO for installation" - echo " --boot-disk Boot from existing virtual disk (after install)" - echo " --clean Remove VM disk and start fresh" - echo " --help Show this help message" + echo " (none) Create VM with single disk and boot from ISO" + echo " --multi-disk Create VM with 2 disks for RAID mirror testing" + echo " --multi-disk=3 Create VM with 3 disks for RAIDZ testing" + echo " --boot-disk Boot from existing virtual disk (after install)" + echo " --clean Remove VM disks and start fresh" + echo " --help Show this help message" echo "" echo "VM Configuration (edit this script to change):" - echo " Disk size: $VM_DISK_SIZE" + echo " Disk size: $VM_DISK_SIZE (per disk)" echo " RAM: ${VM_RAM}MB" echo " CPUs: $VM_CPUS" echo "" echo "SSH into running VM:" - echo " ssh -p 2222 localhost" + echo " ssh -p 2222 root@localhost (password: archzfs)" } # Main check_deps case "${1:-}" in + --multi-disk) + MULTI_DISK=true + NUM_DISKS=2 + boot_iso + ;; + --multi-disk=3) + MULTI_DISK=true + NUM_DISKS=3 + boot_iso + ;; --boot-disk) boot_disk ;; -- cgit v1.2.3