Skip to content
gmircea edited this page May 11, 2020 · 2 revisions

Virtual Machines with QEMU

  • Create disk
qemu-img create -f raw debian9-amd64.img 15G
  • Start machine

Create a shell script:

#!/bin/sh
exec qemu-system-x86_64 -enable-kvm \
     -machine type=pc,accel=kvm \
     -cpu host \
     -smp 2 \
     -m 1536M \
     -drive file=debian9-amd64.img,format=raw,if=virtio \
     -netdev user,id=net0,hostfwd=tcp::22900-:22 \
     -device virtio-net-pci,netdev=net0 \
     -usb \
     -device usb-tablet \
     -name "debian9-amd64" \
     $@

Use qemu-system-i386 if a 32 bit machine is needed.

The above will start a VM with NAT, internet access, SSH server forwarded to localhost port 22900

Start VM: ./qemu-ubuntu.sh

  • Start machine and boot from a ISO

Run the above script with arguments: ./qemu-ubuntu.sh -boot d -cdrom ubuntu-16.04.6-desktop-i386.iso

Clone this wiki locally