Ubuntu 16.04: Install KVM and run virtual machine

This article will describe installing KVM and running virtual machine.

1 Install qemu-kvm and libvirt

Install qemu-kvm package and some packages for virtual machine operation.

$ sudo apt install -y qemu-kvm libvirt0 libvirt-bin virt-manager bridge-utils

Register libvirt-bin to systemd.

$ sudo systemctl enable libvirt-bin

2 Bridge interface

The bridge interface is needed for accessing virtual machine via network from other machine.

3 libvirtd group

The user in libvirtd group can run libvirt command without sudo.

$ sudo gpasswd libvirtd -a <username>

4 Create iso directory

Create iso directory for sharing iso images with libvirtd group. Move ubuntu-16.04-desktop-amd64.iso to iso directory.

$ sudo mkdir /var/lib/libvirt/iso
$ sudo mv ubuntu-16.04-desktop-amd64.iso /var/lib/libvirt/iso/
$ sudo chown libvirt-qemu:libvirtd \

5 Create virtual machine with virt-manager

The virt-manager is a GUI frontend tool for libvirt. Create virtual machine with virt-manager.

$ virt-manager

Click "New Virtual Machine" at the upper left.


Select install media. This article uses ubuntu-16.04-desktop-amd64.iso in iso directory.


Select "Browse" button at "Use ISO image".


The iso directory cannot be found yet. Click "+" icon for adding iso directory. Input storage pool name and select "dir:Filesystem Directory".


Input storage pool path.


The iso directory can be found. Select ubuntu-16.04-desktop-amd64.iso.


ubuntu-16.04-desktop-amd64.iso is selected. Select OS type for memory size calculation. The memory size can be changed after this.


Input core number and memory size.


Create storage.


Select network. "Virtual network 'default': NAT" can be accessed from other machine and "Virtual network 'default': NAT" cannot be accessed. Both network can access to other machine.


OS installation on virtual machine is starting.