alpine / start.sh
mn9206986's picture
Update start.sh
4bd7a22 verified
#!/bin/bash
set -e
DISK="/opt/qemu/alpine.raw"
SEED="/opt/qemu/seed.iso"
RAM="8G"
CORES=4
echo "Starting VM (Q35, 4 cores, CPU max, cache=unsafe)..."
qemu-system-x86_64 \
-smp $CORES,sockets=1,cores=$CORES \
-cpu max \
-m "$RAM" \
-drive file="$DISK",format=raw,if=virtio,cache=unsafe,aio=threads,discard=unmap \
-drive file="$SEED",format=raw,if=virtio,cache=unsafe \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-device virtio-net,netdev=net0 \
-vga virtio \
-display vnc=:0 \
-daemonize \
-machine pc-q35-7.2,accel=tcg \
-rtc base=localtime,clock=host \
-no-shutdown \
-no-reboot
# Start noVNC port 7860
websockify --web=/novnc 7860 localhost:5900 &
echo "================================================"
echo " πŸ–₯️ VNC: http://localhost:7860/vnc.html"
echo " πŸ” SSH: ssh alpine@localhost -p 2222"
echo " 🧾 Login: alpine / root"
echo "================================================"
# Wait SSH
for i in {1..30}; do
nc -z localhost 2222 && echo "βœ… VM ready!" && break
echo "⏳ Waiting SSH..."
sleep 2
done
wait