Skip to content

A guide to QEMU for Ubuntu 24.04 LTS

By default, QEMU installs graphical tools under Gnome. You can administer a virtual machine through Gnome from a console. However, if you’re remotely accessing the machine through RDP this can prove problematic because of RDP woes. With VNC, and CLI commands, you can control a QEMU VM completely over SSH and still access the graphical console.

Setting up a network bridge

Just remember that when setting up the bridge, your physical interface has to be down with nothing tied to it. This means physically accessing the machine unless you have multiple network cards connected. Multiple NICs is handy for firewalls on internet connected systems.

CLI Commands

Some useful CLI commands to be aware of:

-M

sets the machine (chipset) type. q35 is a good baseline.

-usbdevice tablet

is useful for VNC connections because of mouse issues otherwise.

From Stackoverflow, a post describes AHCI emulation:

-drive id=disk,file=IMAGE.img,if=none \
-device ahci,id=ahci \
-device ide-hd,drive=disk,bus=ahci.0

An example on how to create a qcow2 image:

qemu-img create -f qcow2 <filename>.qcow2 <size>

where <size> is the size ending in M or G for megabytes or gigabytes. The qcow2 image format does not allocate space immediately, so can cause issues with some operating systems like OpenBSD. Raw image format will preallocate space. Other image formats are available such as for virtualbox, vmware, parallels, etc.

An example of how to start a Windows 10 image with a bridged network, vnc server, ahci emulation, 16G of RAM, and 12 CPUs.

qemu-system-x86_64 -nographic -enable-kvm -M q35 -m 16384 -cpu host -smp 12 -drive id=disk,cache=writethrough,file=/mnt/qemu/qemu/Windows10.qcow2,format=qcow2,if=none -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -vnc 127.0.0.1:0 -vga cirrus -netdev bridge,id=nd0,br=bridge0 -device e1000,netdev=nd0 -usbdevice tablet

Leave a Reply

Your email address will not be published. Required fields are marked *