Skip to content

qemu | Cheatsheet

QEMU is a free and open-source emulator. It emulates the machine's processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems.


  • vID = Vendor ID for USB
  • pID = Product ID for USB
Option Description
qemu-system-x86_64 Excute qemu
-serial stdio Serial ?
-enable-kvm Enable KVM
-cpu host Emulate the host processor. (Recommended)
-smp 4 Enable cpu + 4 core (-smp $(nproc) for use all)
-device usb-ehci,id=ehci Enable EHCI (2.0)
-device qemu-xhci,id=xhci ENABLE XHCI (3.0)
-device usb-tablet,bus=xhci.0 DONT GRAB THE MOUSE
-net nic -net user ENABLE LAN
-m 4192 RAM MEMORY
-device usb-host,vendorid=\({vID},productid=\) START WITH A USB DEVICE (lsub)
-device usb-host,vendorid=\({vID},productid=\) START WITH A USB DEVICE (lsub)
-hda win7.img Harddrive
-cdrom some.iso Use localetime
cdrom /dev/cdrom Boot from real cdrom slot
-bios /usr/share/edk2-ovmf/OVMF_CODE.fd Boot with UEFI
-localtime Set a virtual CDROM drive and use the host drive for it.
-k keymap Set a keymap
-g 1920x1080 Set resolution

Boot order

Option Description
-boot c Boot the first virtual hard drive
-boot d Boot the first virtual CD-ROM drive
-boot n Boot from virtual network

Display options

Option Description
-display sdl Display video output via SDL
-display curses Displays video output via curses.
-display none Do not display video output
-display gtk Display video output in a GTK window
-display vnc= Start a VNC server on display X

Graphics card

Option Description
-vga cirrus Simple graphics card. Every guest OS has a built-in driver.
-vga std Support resolutions >= 1280x1024x16. Linux, Windows XP and newer guest have a built-in driver
-vga vmware VMware SVGA-II, more powerful graphics card. Install x11-drivers/xf86-video-vmware in Linux guests
-vga qxl More powerful graphics card for use with SPICE. (QXL video causes low resolution)

Audio (Intel HD Audio)

Option Description
-device ich9-intel-hda Add the audio controller
-device hda-output,audiodev=snd0 Add the audio codec and map it to a host audio backend id
-device AC97,audiodev=snd0 Intel 82801AA AC97

Network card

Option Description
-netdev user The QEMU process will create TCP and UDP connections
-device virtio-net,netdev=vmnic -netdev user,id=vmnic (Recommended) Pass-through with VirtIO support.
-netdev user,id=vmnic,hostfwd=tcp: Let QEMU listen on port 9001.
-nic user,hostfwd=tcp::10022-:22 QEMU can forward ports from the host to the guest to enable
-nic user,hostfwd=tcp::10022-:22,hostfwd=tcp::5900-:5900 You can use SSHFS to mount the guest's file system at the host for shared read and write access.
-net nic -net user,smb=shared_dir_path QEMU's built-in SMB server


Option Description
-device virtio-serial-pci Adds a virtio-serial device
-spice port=5930,disable-ticketing=on 5930 for spice channels listening and allow client to connect without authentication

Create harddrive

qemu-img create -f qcow2 foo.img 100G           

Create myimage.img mysize

qemu-img create myimage.img mysize                             

Creates a qcow2 image with a maximum size of 10GB

qemu-img create -f qcow2 foo.img 10G                       

This example increases the size of a qcow2 image

qemu-img resize foo.img 20G                                

Creates a RAW image with a maximum size of 10GB

qemu-img create -f raw foo.img 10G                         

This example increases the size of a RAW image

qemu-img resize -f qcow2 20G                                     

Displays attributes of a RAW image

qemu-img info /var/lib/libvirt/images/disk1.img                

Install virtiofs is required for sharing folders

emerge app-emulation/virtiofsd