2026-01-23 08:55:18 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
|
|
# from vm to make a shared folder
|
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
|
|
|
echo """
|
|
|
|
|
"""
|
|
|
|
|
echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# --- Configurable defaults ---
|
|
|
|
|
IMG=${1:-disc_alpine.qcow2}
|
2026-01-28 18:08:10 +00:00
|
|
|
SSH=${2:-2222}
|
|
|
|
|
SHARE=${3:-$PWD/shared}
|
2026-01-23 08:55:18 +01:00
|
|
|
CPUS=${4:-2}
|
2026-01-28 18:08:10 +00:00
|
|
|
SIZE=${5:-16G}
|
|
|
|
|
RAM=${6:-2G}
|
2026-01-23 08:55:18 +01:00
|
|
|
|
|
|
|
|
# --- Setup ---
|
|
|
|
|
mkdir -p "$SHARE"
|
|
|
|
|
|
|
|
|
|
# --- 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qemu-system-x86_64 \
|
|
|
|
|
-m $RAM \
|
|
|
|
|
-boot once=d \
|
|
|
|
|
-drive file=$IMG \
|
|
|
|
|
-enable-kvm \
|
2026-01-28 18:08:10 +00:00
|
|
|
-display spice-app,show-cursor=on \
|
|
|
|
|
-nic user,hostfwd=tcp::"${SSH}"-:22
|
2026-01-23 08:55:18 +01:00
|
|
|
|