test either installing or running
authorRalph Ronnquist <rrq@rrq.au>
Wed, 18 Sep 2024 11:17:08 +0000 (21:17 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Wed, 18 Sep 2024 11:17:08 +0000 (21:17 +1000)
vm.sh

diff --git a/vm.sh b/vm.sh
index f3493472315f99abdbb43a822833eb8c845c4505..00a0fcdd7c470a423763cd91fd4b0656daf68a27 100755 (executable)
--- a/vm.sh
+++ b/vm.sh
@@ -2,7 +2,25 @@
 
 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)
@@ -26,9 +44,12 @@ ARGS=(
     -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