ARCH=${1:=arm64}
-IMG=disk.raw
+IMG=disk-$ARCH.raw
+if [ -f $IMG ] ; then
+ read -p "(r)un or (i)nstall: " CMD
+ case "$CMD" in
+ r|run)
+ APPEND="root=/dev/vda1"
+ ;;
+ i|install)
+ INITRD="-initrd $ARCH/initrd.gz"
+ ;;
+ *)
+ echo "** Aborted. Need an r or an i..." >&2
+ exit 1
+ ;;
+ esac
+else
+ dd if=/dev/zero of=$IMG bs=1G count=0 seek=4
+ INITRD="-initrd $ARCH/initrd.gz"
+fi
case "$ARCH" in
arm64)
-M virt -cpu $CPU -m 4G
# boot setup
-kernel $ARCH/vmlinuz
- -initrd $ARCH/initrd.gz
+ $INITRD
-append "console=ttyAMA0 root=/dev/vda1 roottype=ext4"
- -serial mon:stdio -echr 0x1c
+ -serial stdio
+ # qemu monitor interface
+ -chardev socket,id=QEMU,server=on,wait=off,path=QEMU
+ -mon chardev=QEMU,mode=readline
# graphics setup
-nographic
# harddrive setup