I've installed Ubuntu 16.04 Desktop on QEMU, but now when I start it with:

qemu-system-i386 -m 1024M -enable-kvm -drive file=./ubuntu-desktop.img,index=0,media=disk,format=raw

I see this picture: enter image description here

Whats going on? How can I fix this?

  • 1
    try -hda rather than -drive and remove all the extra options with drive. Just pass the hard disk file. – user595510 Feb 17 '17 at 23:20
  • Is it possible to use libvirt? – Kong Chun Ho Jun 15 '18 at 8:06

Working Ubuntu 18.04 setup

Tested in an Ubuntu 18.10 host.

enter image description here


#!/usr/bin/env bash

set -eux

# Parameters.

# Get image.
if [ ! -f "$iso" ]; then
  wget "http://releases.ubuntu.com/18.04/${iso}"

# Go through installer manually.
if [ ! -f "$disk_img" ]; then
  qemu-img create -f qcow2 "$disk_img" 1T
  qemu-system-x86_64 \
    -cdrom "$iso" \
    -drive "file=${disk_img},format=qcow2" \
    -enable-kvm \
    -m 2G \
    -smp 2 \

# Create an image based on the original post-installation image
# so as to keep a pristine post-install image.
if [ ! -f "$disk_img_snapshot" ]; then
  qemu-img \
    create \
    -b "$disk_img" \
    -f qcow2 \
    "$disk_img_snapshot" \

# Run the copy of the installed image.
qemu-system-x86_64 \
  -drive "file=${disk_img_snapshot},format=qcow2" \
  -enable-kvm \
  -m 2G \
  -smp 2 \
  -soundhw hda \
  -vga virtio \
  "$@" \

GitHub upstream.

This script will do two QEMU runs:

  • first an installation run. Gets kipped if already done.
  • then a regular boot

The fist time QEMU comes up

  • Install Ubuntu
  • continue, continue, continue...
  • wait a few minutes
  • at the end "Restart now"
  • now you can close the QEMU window

The installer looks like this:

enter image description here

After the install is complete, the script automatically takes a post-install disk snapshot to ubuntu-18.04-desktop-amd64.img.qcow2, and creates a diffed copy to ubuntu-18.04-desktop-amd64.snapshot.qcow2.

It then runs with ubuntu-18.04-desktop-amd64.snapshot.qcow2, and saves any post-regular-boot changes there.

So next time you re-run ./ubuntu-18.04.1-desktop-amd64.sh just starts back from where you last left off.

And if you want to start from the pristine post-manual installation stage to test stuff in a clean environment, you can just:

rm ubuntu-18.04-desktop-amd64.snapshot.qcow2

and the snapshot will be re-generated starting from the clean install.

The snapshot only stores the diffs between the original image, and so it does not take a lot of disk space.

This setup has by default a funky system that automatically resizes the guest resolution to best fit the QEMU window size, you can see this if you either:

  • drag the window with the mouse
  • toggle fullscreen with Ctrl + Alt + F or or start QEMU with -full-screen


TODO clipboard sharing

Tried -spice port=5930,disable-ticketing + remote-viewer spice://, and spice-vdagent is pre-installed on guest, but no success.

The root cause of the mess is that QEMU devs seem more focused on non-interactive usage, rather than implementing things like this reliably and therefore killing VirtualBox once and for all: https://bugs.launchpad.net/qemu/+bug/614958

TODO: host 3D acceleration

Still with SPICE and QXL, glxgears gives 1k FPS, and the exact same with regular SDL. But on host __GL_SYNC_TO_VBLANK=0 vblank_mode=0 glxgears gives 20k FPS, so I'm guessing graphics were not accelerated?

Related: https://unix.stackexchange.com/questions/108122/installing-ubuntu-13-0-desktop-in-qemu

Disable networking (e.g. for malware analysis)

Pass: -nic none on the CLI.

Mentioned at: https://wiki.qemu.org/Documentation/Networking#How_to_disable_network_completely

Share a host directory with the guest

Add to QEMU CLI:

-virtfs local,path=/path/to/share,mount_tag=host0,security_model=mapped,id=host0

and mount on guest with:

sudo mkdir /mnt/9p
mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/9p

More details at: https://superuser.com/questions/628169/how-to-share-a-directory-with-the-host-without-networking-in-qemu/1301973#1301973 That also shows the corresponding fstab entry.

https://serverfault.com/questions/516097/how-to-efficiently-share-hosts-folder-with-kvm-guests claims is is not ultra fast though.

More dedicated question: How to share a folder between KVM host and guest using virt-manager?

This section was tested on Ubuntu 20.04 host.

Prebuilt bootable images

If you want an image that boots without the need for any interaction on the installer, see: Is there any prebuilt QEMU Ubuntu image(32bit) online?


The exact same procedure as mentioned for desktop also worked for the server image.

I just wasn't able to do the initial install with -nogrphic to get rid of the GUI entirely: How to boot and install the Ubuntu server image on QEMU -nographic without the GUI?

But after the initial boot, after editing GRUB configs I achieve that: How to get to the GRUB menu at boot-time using serial console?

However, for the most part, you will likely just want to use the cloud image instead of the server image with emulation, as it does not have the interactive installer, and is usable from the CLI by default.

Tested on an Ubuntu 18.04 host, QEMU 1:2.11+dfsg-1ubuntu7.3, nvidia-384 version 390.48-0ubuntu3, Lenovo ThinkPad P51, NVIDIA Corporation GM107GLM [Quadro M1200 Mobile] GPU.

| improve this answer | |
  • @Downvoters, please explain so I can learn and improve info. Thanks. – Ciro Santilli 郝海东冠状病六四事件法轮功 Apr 28 '19 at 20:44
  • 1
    Tested with a Manjaro Host, an Ubuntu Guest and a Manjaro Guest. Works really good. Thanks – Cristian Rodriguez Apr 13 at 13:06
  • Regarding copy and paste: I was able to get it working but the guest (32-bit Debian 10) is unusably slow although it works fast when QEMU uses VNC. Here's what I did: On the guest: sudo apt install spice-vdagent. On the host (64-bit Arch Linux): qemu-system-x86_64 -drive file=virtualdebian.img -enable-kvm -vga virtio -device virtio-serial-pci -spice unix,addr=/tmp/vm_spice.socket,disable-ticketing -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent. Then connect with: spicy --uri="spice+unix:///tmp/vm_spice.socket" – Matthias Braun Jul 24 at 14:43
  • I don't know what "Add to QEMU CLI:" means. What is the command to access the QEMU CLI in order to add to QEMU CLI? If I can access the QEMU CLI I can figure it out from there. – karel Sep 11 at 10:23
  • 1
    @karel what I mean is: pass those parameters to the QEMU executable on the terminal. The full QEMU command is given in this answer earlier. – Ciro Santilli 郝海东冠状病六四事件法轮功 Sep 11 at 10:31

Installation steps described (by Ciro )worked for me. The cmd line used in script worked fine, But I had to use other options which were causing boot issues after that (booting stops showing storage blocks info)

-vga cirrus helped finally (max 1280 x 1024 resolution). I have nvidia GPU on host with dual monitor setup. Not sure what was causing issue. Also -vga std and -vga virtio didn't work.

Host OS = 16.4 LTS & Guest OS = 18.4.2 LTS

sudo ./x86_64-softmmu/qemu-system-x86_64 -m 8196 -M q35,accel=kvm,kernel-irqchip=split -cpu host -smp 8 -drive file=~/qemu/ubuntu-18.04.2-desktop-amd64.img.qcow2,format=qcow2 -vnc :5 -net nic -net user,hostfwd=tcp::2222-:22 -device intel-iommu,intremap=on **-vga cirrus**

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.