Index

Table of contents

qemu

installation

sudo apt-get install qemu-kvm
sudo apt install qemu-utils

usage

disk image info
qemu-img info disk.img
create disk image (raw format)
qemu-img create disk.img 100G
start qemu with disk only
qemu-system-x86_64 -hda disk.img
start qemu with cd image
qemu-system-x86_64 -hda disk.img -cdrom cd.iso -boot d
disable networking
qemu-system-x86_64 -hda disk.img -net none
enable sound
qemu-system-x86_64 -hda disk.img -soundhw hda
enable vga resolutions on w2k and older
qemu-system-x86_64 -hda disk.img -vga cirrus

performance

specify memory size (default = 128M)
qemu-system-x86_64 -m 4G -hda disk.img
enable kvm for hardware pass through
qemu-system-x86_64 -hda disk.img -enable-kvm
pass more than one cpu to VM
qemu-system-x86_64 -hda disk.img -smp [cpu-count]

shared folders

sharing a folder on host
sudo apt install samba
qemu-system-x86_64 -hda disk.img -net nic -net user,smb=/tmp/foo
mounting from linux vm (root only)
sudo mount -t cifs //10.0.2.4/qemu/ /mnt/host
mounting from linux vm (user permissions)
id
sudo mount -t cifs //10.0.2.4/qemu/ /mnt/host -o username=${user},password=${pswd},uid=${uid},gid=${gid}
unmounting from linux vm
sudo umount /mnt/host

keyboard shortcuts

Toggle mouse and keyboard grab.
Ctrl-Alt
Toggle full screen
Ctrl-Alt-f
Enlarge the screen
Ctrl-Alt-+
Shrink the screen
Ctrl-Alt–
Restore the screen’s un-scaled dimensions
Ctrl-Alt-u
show target system display
Ctrl-Alt-1
show monitor
Ctrl-Alt-2
show serial port
Ctrl-Alt-3

trouble shooting

for permissions if you get the error "Could not acces KVM kernel module: Permission denied"
sudo usermod -aG kvm $(whoami) && sudo reboot

documentation

man qemu-system-x86_64
https://manpages.debian.org/latest/qemu-system-x86/qemu-system-x86_64.1.en.html
https://wiki.archlinux.org/index.php/QEMU#Preparing_a_Windows_guest

GPU passthrough
https://bbs.archlinux.org/viewtopic.php?id=162768
http://vfio.blogspot.com/
https://blog.zerosector.io/2018/07/28/kvm-qemu-windows-10-gpu-passthrough/
https://www.youtube.com/watch?v=SsgI1mkx6iw