How to install KVM on Ubuntu 20.04

KVM (Kernel-based Virtual Machine) is an open source virtualization technology built into the Linux kernel. It allows you to run multiple isolated guest virtual machines based on Linux or Windows. Each client has its own operating system and dedicated virtual hardware, such as CPU(s), memory, network interface and storage.

This guide provides instructions on how to install and configure KVM on Ubuntu 20.04. We will also show you how to create virtual machines, which will be used as development environments for different applications.

1. Prerequisites##

To run a guest with more than 2GB of RAM, you must have a 64-bit host system.

Before proceeding with the installation, make sure that your Ubuntu host supports KVM virtualization. This system must have an Intel processor that supports VT-x (vmx) or an AMD processor that supports AMD-V (svm) technology.

Enter the following grep command to see if your blow supports hardware virtualization:

grep -Eoc '(vmx|svm)'/proc/cpuinfo

If your CPU supports hardware virtualization, this command will print a number greater than 0, which represents the number of CPU cores. Otherwise, if the output is 0, it means that this CPU does not support hardware virtualization.

On some machines, virtualization technology may be disabled by the manufacturer in the BIOS.

To check if VT is enabled in the BIOS, use the kvm-ok tool, which is included in the cpu-checker package. Run the following command as root or another user with sudo privileges to install this package:

sudo apt update
sudo apt install cpu-checker

Once the installation is complete, check whether your system can run a hardware accelerated KVM virtual machine:

kvm-ok

If the processor virtualization capability is not disabled in the BIOS, the command will print out:

INFO:/dev/kvm exists
KVM acceleration can be used

Otherwise, this command will print a failure message and a short message about how to enable the component. The process of enabling AMD-V or VT technology depends on your motherboard and processor type. Configure your system BIOS according to your motherboard documentation information.

2. Install KVM on Ubuntu 20.04

Run the following command to install KVM and additional virtualization management software packages:

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

Once the package is installed, the libvirt daemon will start automatically. You can verify it by running the following command:

sudo systemctl is-active libvirtd

Output:

active

To create and manage virtual machines, you need to add your users to the "libvirt" and "kvm" user groups. enter:

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

$USER is an environment variable used to remember the name of the currently logged in user.

Log out and log in again so that the user group is refreshed.

Three, network settings##

During the libvirt installation process, a bridge device called "virbr0" is created by default. This device uses NAT to connect the client to the outside world.

Run the brctl tool to list the current bridges and the interfaces they are connected to:

brctl show

Output:

bridge name	bridge id		      STP enabled	interfaces
virbr0		  8000.52540089db3f	yes		      virbr0-nic

"Virbr0" bridge does not add any physical interface. "Virbr0-nic" is a virtual device without any traffic passing through. The only purpose of this device is to avoid modifying the MAC address of the "virbr0" bridge.

The network settings are suitable for most Ubuntu desktop users, but there are limitations. If you want to access the client from the outside local network, you need to create a new bridge and configure it so that the client can connect to the outside world through the host's physical interface.

Fourth, create a virtual machine##

Now that KVM is installed on your Ubuntu desktop, let's create the first virtual machine together. We can use the virt-manager application from the command line.

Download the ISO image of the operating system you want to install and follow the steps below to create your virtual machine:

  1. Enter "Virtual Machine Manager" in the search bar and click the icon to launch the application.

  2. After the application is launched, click "File" -> "New Virtual Machine" from the top menu:

  3. A new window will be displayed. Select "Local install media" and click the "Forward" button.

  4. Provide your ISO image path, and click the Forward button.

  5. On the next screen, select the memory and CPU settings of the virtual machine VM. Click Forward.

  6. Next, select "Create a disk image for the virtual machine" and select the disk space size of the virtual machine. Click Forward.

  7. Enter your virtual machine name and click "Finish".

  8. The virtual machine starts, and a new window will open:

From here, you can follow the instructions on the screen to complete the operating system installation.

Once the operating system is installed, you can access it from virt-manager, using ssh or using the Serial Console interface.

Five, summary##

We show you how to install KVM on Ubuntu 20.04 system. Now you can create Windows or Linux clients. To find more information about KVM, browse: KVM Documentation Page.

Recommended Posts

How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ubuntu 19.10 on Raspberry Pi 4
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04
How to install Apache Tomcat 8 on Ubuntu 16.04