Home KVM How To Install KVM On Ubuntu 22.04 Server [A Complete Guide]

How To Install KVM On Ubuntu 22.04 Server [A Complete Guide]

A Complete Guide On Installing KVM On Ubuntu Linux Operating System.

By sk
15.2K views

This detailed guide explains what is KVM hypervisor, how to install KVM on Ubuntu 22.04 server, how to create bridge networking for KVM, and finally how to create KVM virtual machines and manage KVM guest machines using Virsh command line program.

What is KVM?

KVM, short for Kernel-based Virtual Machine, is a FreeBSD and Linux Kernel module that allows the kernel to act as a hypervisor. Starting from kernel version 2.6.20, KVM is merged into Linux kernel mainline.

Using KVM, you can easily setup a virtualization environment in a Linux machine and host a wide range of guest operating systems including Linux, Windows, BSD, Mac OS and many.

In this guide, we will look at how to install and configure KVM hypervisor in Ubuntu 22.04 headless server. And also we will see how to create and manage KVM guest machines using Virsh command line utility.

Prerequisites

Obviously, you need a Ubuntu 20.04 LTS machine to setup KVM. If you haven't installed Ubuntu yet, refer our step by step tutorial to install Ubuntu 22.04 LTS server.

How To Install Ubuntu 22.04 LTS Server Edition

Before installing KVM, first make sure your system's processor supports hardware virtualization. We have documented a few different ways to identify if a Linux system supports Virtualization in the following guide.

How To Find If A CPU Supports Virtualization Technology (VT)

If your system supports hardware virtualization, continue the following steps.

1. Installing KVM on Ubuntu 22.04 LTS Server

For the purpose of this guide, I will be using the following systems.

KVM virtualization server:

  • OS – Ubuntu 22.04 LTS minimal server (No GUI)
  • IP Address : 192.168.1.52/24

Remote Client:

  • OS – Ubuntu 22.04 Server

First, let us install KVM on Ubuntu 22.04 server.

1.1. KVM Installation on Ubuntu

To Install KVM and all other required components to setup a KVM virtualization environment on your Ubuntu 22.04 LTS server, run the following command as sudo user.

$ sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst

Here,

  • qemu-kvm - QEMU metapackage for KVM support (i.e. QEMU Full virtualization on x86 hardware),
  • libvirt-daemon-system - Libvirt daemon configuration files,
  • libvirt-clients - programs for the libvirt library,
  • bridge-utils - utilities for configuring the Linux Ethernet bridge,
  • virtinst - programs to create and clone virtual machines.

Once KVM is installed, start the libvertd service (If it is not started already):

$ sudo systemctl enable libvirtd
$ sudo systemctl start libvirtd

Check the status of libvirtd service with command:

$ systemctl status libvirtd

Sample output:

● libvirtd.service - Virtualization daemon
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-04-11 06:00:33 UTC; 5min ago
TriggeredBy: ● libvirtd.socket
             ● libvirtd-admin.socket
             ● libvirtd-ro.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 5580 (libvirtd)
      Tasks: 21 (limit: 32768)
     Memory: 10.7M
        CPU: 218ms
     CGroup: /system.slice/libvirtd.service
             ├─5580 /usr/sbin/libvirtd
             ├─5718 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_lea>
             └─5719 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_lea>

Apr 11 06:00:33 ubuntuserver systemd[1]: Started Virtualization daemon.
Apr 11 06:00:33 ubuntuserver dnsmasq[5718]: started, version 2.86 cachesize 150
Apr 11 06:00:33 ubuntuserver dnsmasq[5718]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset >
Apr 11 06:00:33 ubuntuserver dnsmasq-dhcp[5718]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Apr 11 06:00:33 ubuntuserver dnsmasq-dhcp[5718]: DHCP, sockets bound exclusively to interface virbr0
Apr 11 06:00:33 ubuntuserver dnsmasq[5718]: reading /etc/resolv.conf
Apr 11 06:00:33 ubuntuserver dnsmasq[5718]: using nameserver 127.0.0.53#53
Apr 11 06:00:33 ubuntuserver dnsmasq[5718]: read /etc/hosts - 7 addresses
Apr 11 06:00:33 ubuntuserver dnsmasq[5718]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Apr 11 06:00:33 ubuntuserver dnsmasq-dhcp[5718]: read /var/lib/libvirt/dnsmasq/default.hostsfile

Well, libvertd service has been enabled and started!

Now add your current user to the kvm and libvirt groups, so they can able to create and manage VMs using virsh command line utility or Virt-manager GUI.

$ sudo usermod -aG kvm $USER
$ sudo usermod -aG libvirt $USER

Alternatively, you can also use the following commands to add the current user to the kvm and libvirt groups.

$ sudo usermod -a -G kvm $(whoami)
$ sudo usermod -a -G libvirt $(whoami)

Let us go ahead and setup Bridged networking for KVM in Ubuntu.

1.2. Setup Bridge Networking with KVM on Ubuntu

A bridged network shares the real network interface of the host computer with other VMs to connect to the outside network. Therefore each VM can bind directly to any available IPv4 or IPv6 addresses, just like a physical computer.

By default KVM setups a private virtual bridge, so that all VMs can communicate with one another, within the host computer. It provides its own subnet and DHCP to configure the guest’s network and uses NAT to access the host network.

Let us have a look at the IP address of the KVM default virtual interfaces using "ip" command:

$ ip a

Sample output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp6s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 1e:9a:85:d4:37:4a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.22/24 brd 192.168.1.255 scope global enp6s18
       valid_lft forever preferred_lft forever
    inet6 fe80::1c9a:85ff:fed4:374a/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:89:d4:9a brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
Check KVM Default Virtual Interface IP Address
Check KVM Default Virtual Interface IP Address

As you can see, KVM default network virbr0 uses 192.168.122.1/24 IP address. All the VMs will use an IP address in the 192.168.122.0/24 IP range and the host OS will be reachable at 192.168.122.1. You should be able to ssh into the host OS (at 192.168.122.1) from inside the guest OS and use scp to copy files back and forth.

It is OK if you only access the VMs inside from the host itself. However you can't access the VMs from other remote systems in the network.

Because those remote systems have been using different IP range i.e. 192.168.1.0/24 in my case. In order to access the VMs from other remote hosts, we must setup a public bridge that runs on the host network and uses whatever external DHCP server is on the host network.

To put this in layman terms, we are going to make all VMs to use the same IP series used by the host system.

Before setting up a public bridged network, we should disable Netfilter for performance and security reasons. Netfilter is currently enabled on bridges by default.

To disable netfilter, create a file named /etc/sysctl.d/bridge.conf:

$ sudo vi /etc/sysctl.d/bridge.conf

Press i to switch to insert mode and add the following lines:

net.bridge.bridge-nf-call-ip6tables=0
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0

After adding the above lines, press ESC key and type :wq to save the file and close it.

Then create another file named /etc/udev/rules.d/99-bridge.rules:

$ sudo vi /etc/udev/rules.d/99-bridge.rules

Add the following line:

ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", RUN+="/sbin/sysctl -p /etc/sysctl.d/bridge.conf"

This will set the necessary flags to disable netfilter on bridges at the appropriate place in system start-up. Save and close the file. Reboot your system to take effect these changes.

Next, we should disable the default networking that KVM installed for itself.

Find the name of KVM default network interfaces using ip link command:

$ ip link

Sample output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp6s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 1e:9a:85:d4:37:4a brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:89:d4:9a brd ff:ff:ff:ff:ff:ff
View KVM Default Virtual Network Interfaces
View KVM Default Virtual Network Interfaces

As you see in the above output, the "virbr0" is the KVM network interface. Also make a note of the your physical network interface's (i.e. enp6s18) mac address . In my case, the mac address of enp6s18 is 1e:9a:85:d4:37:4a.

Now, let us remove the default KVM network with command:

$ virsh net-destroy default

Sample output:

Network default destroyed

Undefine the default network with command:

$ virsh net-undefine default

Sample output:

Network default has been undefined
Delete Default KVM Network Interfaces
Delete Default KVM Network Interfaces

If the above commands doesn't work for any reason, you can use these commands to disable and undefine KVM default network:

$ sudo ip link delete virbr0 type bridge

Now run ip link again to verify if the virbr0 and/or virbr0-nic interfaces are actually deleted:

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp6s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 1e:9a:85:d4:37:4a brd ff:ff:ff:ff:ff:ff

See? The KVM default network is gone.

Now, let us setup the KVM public bridge to use when creating a new VM.

Heads Up: Do not use wireless network interface cards for bridges. Most wireless interlaces do not support bridging. Always use wired network interfaces for seamless connectivity!

To create a KVM network bridge in Ubuntu server, edit /etc/netplan/00-installer-config.yaml file and add the bridge details.

Here is the default contents of the 00-installer-config.yaml file in my Ubuntu 22.04 LTS server.

$ cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp6s18:
      addresses:
      - 192.168.1.22/24
      gateway4: 192.168.1.101
      nameservers:
        addresses:
        - 8.8.8.8
        - 1.1.1.1
        search: []
  version: 2

As you see, I have one wired network interface named enp6s18 in my Ubuntu server.

Before editing this file, backup your existing /etc/netplan/00-installer-config.yaml file:

$ sudo cp /etc/netplan/00-installer-config.yaml{,.backup}

Then edit the default config file using your favorite editor:

$ sudo vi /etc/netplan/00-installer-config.yaml

Add/modify it like below.

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp6s18:
      dhcp4: false
      dhcp6: false

  # Add configuration for bridge interface
  bridges:
    br0:
      interfaces: [enp6s18]
      addresses: [192.168.1.52/24]
      routes:
        - to: default
          via: 192.168.1.101
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
        search: []
      parameters:
        stp: true
        forward-delay: 4
  version: 2
Configure KVM Bridge Network in Ubuntu Linux
Configure KVM Bridge Network in Ubuntu Linux

Here, the bridge network interface br0 is attached to host's network interface enp6s18. The IP address of br0 is 192.168.1.52. The gateway is 192.168.1.101. I use Google DNS servers (8.8.8.8 and 8.8.4.4) to connect to Internet. You must replace the above values that matches with your network.

Heads Up: Make sure the space indentations are exactly same as above. If the line indentations are not correct, the bridged network interface will not activate.

After modifying the network config file, save the file and close it.

Check if there are any netplan configuration errors using command:

$ sudo netplan generate

You will see nothing in the output if you don't have any configuration issues.

Apply the changes by running the following command:

$ sudo netplan --debug  apply

Heads Up: If you use different IP addresses for your physical NIC and KVM bridge interface, the SSH connection to the KVM host will be terminated as soon as you run the above command. You may need to reconnect to the SSH session using the new IP address assigned for the bridge network interface. If you use same IP address for both physical NIC and KVM Bridge interface, you won't have this connectivity issue.

Now check if the IP address has been assigned to the bridge interface:

$ ip a

Sample output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp6s18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether 1e:9a:85:d4:37:4a brd ff:ff:ff:ff:ff:ff
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 62:2e:01:a1:7e:7a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.52/24 brd 192.168.1.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::602e:1ff:fea1:7e7a/64 scope link 
       valid_lft forever preferred_lft forever
Check KVM Network Bridge IP Address
Check KVM Network Bridge IP Address

As you see in the above output, the bridged network interface br0 is assigned with IP address 192.168.1.52 and the enp6s18 entry now has "master br0" entry. It means that enp6s18 belongs to the bridge.

You can also use brctl command to show the KVM bridge network status:

$ brctl show br0

Sample output:

bridge name	bridge id		STP enabled	interfaces
br0		8000.622e01a17e7a	yes		enp6s18

We have completed KVM bridge network configuration. Let us move on configure network bridge for KVM virtual machines.

1.3. Add Bridge Network to KVM

In this step, we are going to configure KVM to use this bridge. To do that, create a an XML file called host-bridge.xml:

$ vi host-bridge.xml

Add the following lines:

<network>
  <name>host-bridge</name>
  <forward mode="bridge"/>
  <bridge name="br0"/>
</network>

Run the following commands to start the newly created bridge and make it as default bridge for VMs:

$ virsh net-define host-bridge.xml
$ virsh net-start host-bridge
$ virsh net-autostart host-bridge
Start KVM Host Bridge
Start KVM Host Bridge

To verify if the KVM host bridge is active and started, run:

$ virsh net-list --all

Sample output:

Name          State    Autostart   Persistent
------------------------------------------------
 host-bridge   active   yes         yes
Check KVM Host Bridge Status
Check KVM Host Bridge Status

Congratulations! We have successfully setup KVM networking bridge and it is active now.

At this stage, you should have a working KVM installation on Ubuntu 22.04 LTS server with KVM bridge networking configured. It is time to deploy some virtual machines and manage them.

2. Create KVM Virtual Machines using virsh Command

We can use the virsh command line utility to create and manage virtual machines. The virsh command is used create, list, pause, restart, shutdown and delete VMs from command line.

By default, the virtual machine files and other related files are stored under /var/lib/libvirt/ location. The default path to store ISO images is /var/lib/libvirt/boot/. We can of course change these locations when installing a new VM.

2.1. List all Virtual Machines

First, let us check if there are any virtual machines exists.

To view the list of all available virtual machines, run:

$ sudo virsh list --all

Sample output:

List all KVM Virtual Machines using virsh Command
List all KVM Virtual Machines using virsh Command

As you can see, there are no existing virtual machines.

2.2. Upload ISO Images

Before creating our first VM, we have to upload the ISO image to /var/lib/libvirt/boot/ directory.

Go to the location where you stored ISO image files and copy the ISO file to /var/lib/linvirt/boot/ directory. For instance, I have copied Ubuntu 22.04 server ISO to to /var/lib/linvirt/boot/ directory.

$ sudo cp ubuntu-22.04-live-server-amd64.iso /var/lib/libvirt/boot/

2.3. Create KVM Virtual Machines

Let us create an Ubuntu 22.04 Virtual machine with 4 GB RAM, 2 CPU core, 20 GB Hdd. To do that, run:

$ sudo virt-install --name Ubuntu-22.04 --ram=4096 --vcpus=2 --cpu host --hvm --disk path=/var/lib/libvirt/images/ubuntu-22.04-vm1,size=10 --cdrom /var/lib/libvirt/boot/ubuntu-22.04-live-server-amd64.iso --network bridge=br0 --graphics vnc

Let us break down the above command and see what each option do.

  • --name Ubuntu-22.04 : The name of the virtual machine
  • --ram=4096 : Allocates 4 GB RAM to the VM.
  • --vcpus=2 : Indicates the number of CPU cores in the VM.
  • --cpu host : Optimizes the CPU properties for the VM by exposing the host’s CPU’s configuration to the guest.
  • --hvm : Request the full hardware virtualization.
  • --disk path=/var/lib/libvirt/images/ubuntu-22.04-vm1,size=10 : The location to save VM’s hdd and it’s size. In this case, I have allocated 10 GB hdd size.
  • --cdrom /var/lib/libvirt/boot/ubuntu-22.04-live-server-amd64.iso : The location where you have the actual Ubuntu installer ISO image.
  • --network bridge=br0 : Instruct the VM to use bridge network. If you don't configured bridge network, ignore this parameter.
  • --graphics vnc : Allows VNC access to the VM from a remote client.

Sample output:

WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING  No console to launch for the guest, defaulting to --wait -1

Starting install...
Allocating 'ubuntu-22.04-vm1'                                                                                              |    0 B  00:00:00 ... 
Creating domain...                                                                                                         |    0 B  00:00:00     

Domain is still running. Installation may be in progress.
Waiting for the installation to complete.
Create KVM Virtual Machine from Command line
Create KVM Virtual Machine from Command line

This message will keep showing until you connect to the VM from a remote system via any VNC application and complete the OS installation.

Since our KVM host system (Ubuntu server) doesn't has GUI, we can't continue the guest OS installation from the host system itself. So, I am going to use a spare machine that has GUI on it to complete the guest OS installation with the help of a VNC client.

We are done with the Ubuntu server here. The following steps should be performed on a client system.

2.4. Access KVM Virtual Machines via VNC Client

Go to another system that has graphical desktop environment and install your preferred VNC client application (E.g. Remmina or Remote-viewer). I have a Ubuntu desktop with Remmina remote desktop client installed.

Open a new Terminal window and SSH into the KVM host system:

$ ssh ostechnix@192.168.1.52

Here,

  • ostechnix is the name of the user in KVM host (Ubuntu 22.04 server)
  • 192.168.1.52 is the IP address of KVM host.

Find the VNC port used by the running VM using command:

$ sudo virsh dumpxml Ubuntu-22.04 | grep vnc

Replace "Ubuntu-22.04" with your VM's name.

Sample output:

<graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>

The VNC port numer is 5900.

Now disconnect from the KVM host's SSH session and run the following SSH port forwarding command from your local system's terminal:

$ ssh ostechnix@192.168.1.52 -L 5900:127.0.0.1:5900

2.4.1. Access Virtual Machines using Remmina

Launch Remmina client application and choose "VNC" protocol and then type "localhost:5900" in the address bar and finally hit ENTER:

Connect to remote virtual machines using Remmina remote desktop client
Connect to remote virtual machines using Remmina remote desktop client

The Remmina application will now show you the guess OS installation window.

Access Virtual Machines via Remmina VNC Client
Access Virtual Machines via Remmina VNC Client

2.4.2. Access Virtual Machines using Remote-viewer

If you have Remote-viewer application installed on your local system, open it and type "vnc://localhost:5900" in the address bar and click Connect.

Connect to KVM Virtual Machine via Remote-viewer Application
Connect to KVM Virtual Machine via Remote-viewer Application

Now you will able to access the KVM Virtual machine's console.

Access KVM Virtual Machine via Remote-viewer
Access KVM Virtual Machine via Remote-viewer

Alternatively. you can connect to the KVM virtual machine via Remote-viewer app by running he following command:

$ remote-viewer vnc://localhost:5900

This command will open the Virt-viewer application and you can access the virtual machine installation window via Remote-viewer.

Just continue the guest OS installation. Once the installation is done, you can either continue using the newly install Ubuntu system via Remmina or Remote-viewer or access it via SSH. After done with the VM, simply close the VNC application window.

3. Manage KVM Virtual Machines using virsh Command

Here are some most-commonly used virsh command examples to manage KVM virtual machines from command line using virsh command.

3.1. List Running VMs

Run virsh list command to see the list of running VMs:

$ sudo virsh list

Sample output:

 Id   Name           State
------------------------------
 2    Ubuntu-22.04   running

As you can see, Ubuntu 22.04 VM is currently running and its ID is 2.

To view all VMs (both running and stopped), use --all flag.

$ sudo virsh list --all
List KVM Virtual Machines using virsh Command
List KVM Virtual Machines using virsh Command

3.2. Start VMs

To start a VM, the following command can be used:

$ sudo virsh start VM_NAME

Example:

$ sudo virsh start Ubuntu-22.04

You can also use the VM's ID to start it:

$ sudo virsh start 2

3.3. Restart VMs

To restart a running VM, do:

$ sudo virsh reboot Ubuntu-22.04

Or,

$ sudo reboot 2

3.4. Pause VMs

To pause a running VM, do:

$ sudo suspend Ubuntu-22.04

Or,

$ sudo suspend 2

3.5. Resume VMs

To resume a suspended VM, do:

$ sudo virsh resume Ubuntu-22.04

Or,

$ sudo resume 2

3.6. Shutdown VMs

To power off a running VM, do:

$ sudo virsh shutdown Ubuntu-22.04

Or,

$ sudo shutdown 2

3.7. Delete VMs

To completely remove a VM, do:

$ sudo virsh undefine Ubuntu-22.04
$ sudo virsh destroy Ubuntu-22.04

Virsh has a lots of commands and options. To learn all of them, refer virsh help section:

$ virsh --help

4. Manage KVM Guests Graphically

Remembering all virsh commands is nearly impossible. If you are budding Linux admin, you may find it hard to perform all KVM management operations from command line. No worries! There are some great web-based tools available to manage KVM guest machines graphically. The following guides explains how to manage KVM guests using Cockpit and Virt-manager in detail.

5. Enable Virsh Console Access for Virtual Machines

After creating the KVM guests, I can be able to access them via SSH, VNC client, Virt-viewer, Virt-manager and Cockpit web console etc. But I couldn't access them using virsh console command. To access KVM guests using virsh console, refer the following guide:

How To Enable Virsh Console Access For KVM Guests

Conclusion

In this guide, we discussed how to install and configure KVM in Ubuntu 22.04 LTS server edition. And then, we looked at how to configure KVM bridge network in Ubuntu.

Next we learned how to create and manage KVM virtual machines from command line using virsh tool and using GUI tools Cockpit and Virt-manager.

Finally, we saw how to enable virsh console access for KVM virtual machines.

At this stage, you should have fully working KVM virtualization environment on your Ubuntu 22.04 server.

KVM is a vast topic. I strongly suggest you to go through all other KVM topics given below. I will continuously update this guide with new KVM-related topics. I recommend you to bookmark this link and come back once in a while to see if any new topic is added.

Resource:

Featured Image by Jonathan Hammond from Pixabay.

You May Also Like

4 comments

Bleskocvok May 2, 2023 - 10:08 am

Thanks for this great tutorial. I struggled for two days how to set up the same thing in Red Hat’s Copilot (namely how to expose VMs to LAN) to no avail. So after ditching the fancy web interface I was finally able to do it in the good ol’ terminal way thanks to these instructions.

Perhaps it would’ve been nice to also include some information about installing a VM with –graphics none (for e.g. Ubuntu Server), which I had to grab from a different tutorial.

Reply
sk May 2, 2023 - 11:23 am

Glad I could help. I will add this to my to-do list. Thanks.

Reply
MarKomus May 22, 2023 - 1:26 am

Hello! I followed your tutorial until I got to the part about KVM automatically setting up the private virtual bridge. When I type the command “ip a” I get only the loopback and the default devices. I’m wondering if my /22 network is confusing KVM? 🙂

Reply
sk May 22, 2023 - 11:36 am

There is no such part “Automatically setup private bridge” in this guide. Please follow the instructions carefully given in the section “1.2. Setup Bridge Networking with KVM on Ubuntu”. It should work.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More