QEMU cheatsheet

tags: linux, qemu, vm, virtualization

Create disk image

Creates 3 GB large image named centos.img:

qemu-img create -f qcow2 centos.img 3G

Resize disk image

qemu-img resize centos.img +1024M

Run VM

Run Centos VM using image centos.img, allocate 1024 MB ram, boot from CD-ROM using CentOS-7.iso:

qemu-system-x86_64 -m 1024 \
  -enable-kvm \
  -boot d \
  -cdrom CentOS-7.iso \
  centos.img

Set up NAT networking with TAP interface

See qemu-guest-network-in-nat-mode