Files
svr/usr/sbin/arch-qemu-install
T
dangerboot aeb2f0c167 modified: usr/sbin/arch-qemu-install
modified:   usr/sbin/basha
2026-03-10 19:16:17 +01:00

41 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -eux
# from vm to make a shared folder
echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt"
# --- Configurable defaults ---
ISO_URL="https://mirror.arizona.edu/archlinux/iso/latest/archlinux-x86_64.iso"
ISO=${1:-$(basename $ISO_URL)}
IMG=${2:-disk_qemu.qcow2}
SIZE=${3:-16G}
RAM=${4:-2G}
CPUS=${5:-2}
SHARE=${6:-$PWD/share}
# --- Setup ---
mkdir -p "$SHARE"
echo "iso = $ISO"
[ -f "$ISO" ] || wget "$ISO_URL"
[ -f "$IMG" ] || qemu-img create -o nocow=on -f qcow2 "$IMG" "$SIZE"
# --- Optional install script ---
# Drop any file named install.sh in ./share to execute it inside the VM later:
# e.g. `bash /mnt/share/install.sh` after mounting
# --- Run QEMU with graphics + shared folder ---
qemu-system-x86_64 \
-enable-kvm \
-m "$RAM" \
-cpu host \
-smp "$CPUS" \
-cdrom "$ISO" \
-nic user \
-drive file="$IMG",format=qcow
#-boot d \
# -netdev user,id=net0,dns=1.1.1.1 \
# -device virtio-net-pci,netdev=net0 \
# -display default,show-cursor=on \
# -virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare