Skip to content

Instantly share code, notes, and snippets.

@junedkhatri31
Created October 30, 2020 17:02
Show Gist options
  • Save junedkhatri31/bc7cef624acf21115f4580d3f6748e41 to your computer and use it in GitHub Desktop.
Save junedkhatri31/bc7cef624acf21115f4580d3f6748e41 to your computer and use it in GitHub Desktop.
Boot VM using qemu
### create_storage.sh
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "You must enter exactly 1 command line arguments"
fi
qemu-img create -f qcow2 storages/$1.img 10G
### start_vm.sh
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "You must enter exactly 1 command line arguments"
fi
vm_name=$1
qemu-system-x86_64 \
-enable-kvm \
-m 2048 \
-smp 2 \
-cpu host \
-soundhw es1370 \
-device virtio-mouse-pci -device virtio-keyboard-pci \
-serial mon:stdio \
-boot menu=on \
-net nic \
-net user,hostfwd=tcp::5555-:22 \
-device virtio-vga,virgl=on \
-display gtk,gl=on \
-hda storages/$vm_name.img \
-cdrom images/$vm_name.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment