30 lines
613 B
Bash
Executable file
30 lines
613 B
Bash
Executable file
#!/bin/sh
|
|
|
|
path=$1;
|
|
DISK_GB=4;
|
|
CPU_COUNT=8;
|
|
MEM_MB=2048;
|
|
|
|
if [ $# -eq 0 ]; then
|
|
name="vm_$(date +%s)"
|
|
path="/tmp/$name"
|
|
fi
|
|
|
|
echo "[mk_vm.sh] creating '$path'";
|
|
|
|
mkdir -p "$path";
|
|
cd "$path";
|
|
|
|
if ! [ -f ./arch.iso ]; then
|
|
wget "http://archlinux.mirrors.ovh.net/archlinux/iso/latest/archlinux-x86_64.iso" -O "./arch.iso";
|
|
fi
|
|
|
|
if ! [ -f ./root.img ]; then
|
|
qemu-img create root.img "$DISK_GB"G;
|
|
fi
|
|
|
|
# ARGS_GRAPHICS="-display egl-headless"
|
|
# ARGS_GRAPHICS="-nographic"
|
|
|
|
ARGS="-drive file=root.img,format=raw -cdrom arch.iso -boot d -smp $CPU_COUNT -m $MEM_MB $ARGS_GRAPHICS"
|
|
screen -S vm qemu-system-x86_64 $ARGS;
|