Created
March 31, 2020 01:04
-
-
Save mdhorn/5d4bbc1aadf97d82a2877560ba5f45f7 to your computer and use it in GitHub Desktop.
Start QEMU with extra disk for install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- | |
# ex: ts=8 sw=4 sts=4 et filetype=sh | |
# | |
# start_qemu.sh | |
# | |
# Copyright (c) 2016 Intel Corporation | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
# | |
if [ -z "$1" ]; then | |
IMAGE=clear.img | |
else | |
IMAGE="$1" | |
shift | |
fi | |
if [ -z "$1" ]; then | |
IMAGE2="" | |
else | |
TARGET_IMAGE_SIZE="$1" | |
shift | |
TARGET_IMAGE="/tmp/spare_media.img" | |
rm -f ${TARGET_IMAGE} | |
echo "Creating empty image file '${TARGET_IMAGE}' of size ${TARGET_IMAGE_SIZE}..." | |
/usr/bin/qemu-img create -f raw ${TARGET_IMAGE} ${TARGET_IMAGE_SIZE} | |
IMAGE2="-drive file=${TARGET_IMAGE},if=virtio,aio=threads,format=raw" | |
fi | |
VNC="" | |
VNC="-vnc 0.0.0.0:0" | |
if [ -z "$1" ]; then | |
GRAPHICS="-vga none -nographic" | |
else | |
GRAPHICS="" | |
shift | |
fi | |
if [[ "$IMAGE" =~ .xz$ ]]; then | |
>&2 echo "File \"$IMAGE\" is still xz compressed. Uncompress it first with \"unxz\"" | |
exit 1 | |
fi | |
if [ ! -f "$IMAGE" ]; then | |
>&2 echo "Can't find image file \"$IMAGE\"" | |
exit 1 | |
fi | |
rm -f debug.log | |
VMN=${VMN:=1} | |
#-object secret,id=sec0,data=P@ssW0rd \ | |
#-drive driver=luks,key-secret=sec0,file="$IMAGE",if=virtio,aio=threads \ | |
# -cpu Broadwell \ | |
qemu-system-x86_64 \ | |
-enable-kvm \ | |
-bios OVMF.fd \ | |
-boot menu=on,order=cd,once=dc \ | |
-smp sockets=1,cpus=4,cores=2 -cpu host \ | |
-m 4096 \ | |
$GRAPHICS \ | |
-drive file="$IMAGE",if=virtio,aio=threads,format=raw \ | |
$IMAGE2 \ | |
-netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375,dnssearch=intel.com \ | |
-device virtio-net-pci,netdev=mynet0 \ | |
-debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment