How to Install and Configure KVM on Ubuntu 18.04 LTS Server

20 Responses

  1. Mac says:

    Great article.. straight to the point..

  2. Steve says:

    Helpful – but virt-install wasn’t recognised for me, I had to install virtinst also:
    sudo apt install virtinst
    Also I needed to replace –location with –cdrom and remove the extra-args (even though I was not using a cd rom, otherwise I got a ‘Couldn’t find hvm kernel .. error)

    • Smarty says:

      Its because of wrong ISO! Do not use the cloud based standard version – instead use the alternativ: at the moment:
      If you get an Error 404 there is a newer version. Check instead

  3. Gannet says:

    I think it is better to remove netplan and use networkd to configure network including bridges. But thanks for how to use netplan for creating bridges. Now I know it.

  4. Chitzle says:

    Sorry if this is sill question but why do we configure the br0 with a static IP and not the hardware interface ens33? Does this result in the host and the guest OS using the same IP?

    • Pradeep Kumar says:

      Hi Chitzle,

      If you want your virtual machines to be accessed from outside of KVM host then you need to create a bridge, remove the IP from eth0 or ens33 and assign the same ip to bridge interface.
      Map VMs interface to the bridge either via command line or virt-manager.After that you can assign the IP from the VLAN which is associated to bridge.

      • Eric says:

        Could one instead configure the host machine as a router, forwarding packets between its physical interface and a separate virtual interface, the latter of which would be the gateway for guest machines’ interfaces?

  5. MikeP says:

    Everything seemed to work, but I don’t see the new vm assigned its own IP via dhcp as I expected.
    ‘This is my xml dump

    virsh dumpxml Node01









  6. MAksym says:


    ALWAYS use YAML validators BEFORE you make ANY changes in vi /etc/netplan/50-cloud-init.yaml

    Thanks author for article.

  7. Arvind Pal says:

    Very nice article, step by step very helpful, Thanks

  8. Michael Cooper says:

    You must have installed this on a desktop because I cannot get virt-manager to work I get an error that it cannot start because of something with GTK-warning

    [email protected]:~$ sudo virt-manager
    [email protected]:~$ Unable to init server: Could not connect: Connection refused
    Unable to init server: Could not connect: Connection refused
    Unable to init server: Could not connect: Connection refused

    (virt-manager:1875): Gtk-WARNING **: 17:59:02.848: cannot open display:

    Anyone have a luce as to why it’s not starting?


  9. anonym says:

    The following packages have unmet dependencies:
    virt-manager : Depends: python2.7 but it is not going to be installed
    Depends: python:any (>= 2.7.5-5~)
    Depends: python-gi but it is not going to be installed
    Depends: python-gi-cairo but it is not going to be installed
    Depends: python-dbus but it is not going to be installed
    Depends: python-requests but it is not going to be installed
    Depends: python-libvirt (>= 0.7.1) but it is not going to be installed
    Depends: virtinst (>= 1:1.5.1-0ubuntu1) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    And I can not install python2.7 🙁

  10. JV says:

    Step:4 .. are you adding or editing your current file?
    if I add the suggested settings then I lose network connection.
    How does the final full file of 50-cloud-init.yaml look like?

    • Pradeep Kumar says:

      Hi ,

      You should not loose your network connection as we are assigning the same IP of our Lan card to a bridge. In my case i am editing the existing file.

      Make sure you put lines in correct format as it a YAML file.

  11. Askar says:

    To check virtualization support the command should be …
    egrep -c ‘(vmx|svm)’ /proc/cpuinfo

  12. Cristian Arriaza says:

    You are the best thank you very much, better than on the manufacturer’s website 🙂

  13. Eric says:

    Do I understand correctly from Step 5 that one can be logged into a headless U 18.04 server via ssh and run the graphical virt-manager utility? Even in the absence of a local graphical environment?

    If so, how must ssh be configured? Is it just a question of setting X11Forwarding=yes in the respective ssh_config and sshd_config files?

  14. Tony says:

    You’ll also need to install a X server on your host machine (for Windows, I recommend vcxsrv, open source and updated).

Leave a Reply

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