Prepare an empty 4G disk.raw unless there is one already.
[rrq/rescue-boot.git] / run.sh
1 #!/bin/bash
2
3 DISK=disk.raw
4 [ -f $DISK ] || dd if=/dev/null of=$DISK bs=1G count=0 seek=4
5 CD=$1
6 FS=FS.sqfs
7 PCODE=/usr/share/OVMF/OVMF_CODE_4M.fd
8 PVARS=/usr/share/OVMF/OVMF_VARS_4M.fd
9 cp $PVARS pvars.bin
10 if [ -n "$EFI" ] ; then
11     EFI="
12     -drive if=pflash,readonly=on,format=raw,file=$PCODE
13     -drive if=pflash,readonly=off,format=raw,file=pvars.bin
14 "
15 fi
16 NET="-nic vde,sock=/run/vde.ctl,model=e1000,mac=06:38:d0:34:20:d2"
17 QEMU=qemu-system-x86_64
18 [ -z "${CD##*i386*}" ] && QEMU=qemu-system-i386
19 exec $QEMU -name "${CD%.img}" -m 2G -M pc,accel=kvm -cpu host \
20     -drive media=disk,format=raw,file=$CD \
21     -drive media=disk,format=raw,file=$DISK \
22     -virtfs local,path=FS,mount_tag=FS,security_model=passthrough \
23     -serial mon:stdio -echr 0x1c -vga std \
24     $EFI $NET
25 #    -boot menu=on,splash-time=60000 \
26 #    -kernel FS/vmlinuz -initrd FS/initrd.img \
27 #    -append "root=FS rootfstype=9p console=ttyS0"