I am trying to boot my very first VM using KVM. I have Ubuntu 12.04 installed, i made sure the BIOS had the right virtualization flag enabled for intel processor by running kvm-ok. I have researched this on google and all the instructions that i have found so far are outdated. for e.g. most instructions talk about booting a virtual machine with the following commands

Create a virtual disk for your VM:

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

This runs kvm:

kvm --name foo -m 1024 -hda foo.img -cdrom whatever.iso -boot d

This command line is incomplete. First you need to be root to run this. Second, it is missing option for the video device. When you run this command you get the following error:

Could not initialize SDL(No available video device) - exiting

Googled this error and looked it up on StackOverflow. The answer provided in that thread does not work on Ubuntu 12.04.

Googled this problem further and found out that I need to specify a video device so I finally ran the following command:

sudo kvm --name mymachine -m 8096 -hda myimage.img --cdrom ubuntu.iso -boot d -vga cirruss -k en-us -vmc :0

This was after I had created the myimage.img image on the drive. Now this command does not give me an error but it just hangs.

Does anyone have clear instructions on how to run a VM using KVM on Ubuntu?


as said by Michael Hampton♦ you can use virt-manager to create vm.


apt-get install virt-manager

on the host to install and after that you can use virt-manager to create new vms, also you will not face issues like above as libvirt takes care of that.


Specifically for the problem of not having graphics, try the -nographic option. Using this I was able to boot an Ubuntu snappy guest image on an Ubuntu 14.04 host. A headless host, logged in via SSH.


The error is misleading: it is in fact because qemu can't connect to your X session. To run X programs as a different user you need to either preserve your environment:

sudo -E kvm ...

or use xhost, e.g.

xhost +si:localuser:root

or set root's XAUTHORITY environment variable to point to your $HOME/.Xauthority file.


I usually create an XML file with all of the settings, then use virsh define file.xml and then virsh start VMname (as defined in file.xml). Use a VNC client to view the VM as it boots. I usually use netstat -alntp |grep 59.. and look for the qemu-vnc instances to see what ports are being used for VNC.

Here is how to create the XM file http://libvirt.org/formatdomain.html

  • Or just use virt-manager. – Michael Hampton Nov 4 '13 at 21:58
  • Can you please elaborate on your answer on how to use virt-manager – CrazycodeMonkey Nov 7 '13 at 20:11
  • @CrazycodeMonkey What part of it are you having trouble with? It's fairly self-explanatory. – Michael Hampton Dec 9 '14 at 23:01

I strongly recommend you to avoid using any tool but qemu itself. HW emulation is qemu's responsibility. by default it can handle many configuration options. as in your situation you can change your kvm command's qemu equivalent with improved virtio.

sudo qemu-system-x86_64 -enable-kvm -name mymachine -m 8192 -drive media=disk,cache=none,index=0,file=myimage.img,if=virtio,format=qcow2,aio=native -boot d -vnc :1,password -usbdevice tablet -monitor tcp:,server

You can change VNC password with qemu monitor.

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.