How to Install Kvm on Ubuntu 20.04

[ad_1]

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

This guide provides instructions on how to install and configure KVM on Ubuntu 20.04 desktop. We’ll also show you how to create virtual machines that can be used as a development environment for different applications.

Prerequisites #

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

Before continuing with the installation, make sure your Ubuntu host machine supports KVM virtualization. The system should have either an Intel processor with the VT-x (vmx), or an AMD processor with the AMD-V (svm) technology support.

Run the following grep
command to verify that your processor supports hardware virtualization:

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

If the CPU supports hardware virtualization, the command will output a number greater than zero, which is the number of the CPU cores. Otherwise, if the output is 0 it means that the CPU doesn’t support hardware virtualization.

On some machines, the virtual technology extensions may be disabled in the BIOS by the manufacturers.

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

sudo apt updatesudo apt install cpu-checker

Once installed, check if your system can run hardware-accelerated KVM virtual machines:

kvm-ok

If the processor virtualization capability is not disabled in the BIOS the output will look something like this:

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

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

Installing KVM on Ubuntu 20.04 #

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

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager
  • qemu-kvm – software that provides hardware emulation for the KVM hypervisor.
  • libvirt-daemon-system – configuration files to run the libvirt daemon as a system service.
  • libvirt-clients – software for managing virtualization platforms.
  • bridge-utils – a set of command-line tools for configuring ethernet bridges.
  • virtinst – a set of command-line tools for creating virtual machines.
  • virt-manager – an easy-to-use GUI interface and supporting command-line utilities for managing virtual machines through libvirt.

Once the packages are installed, the libvirt daemon will start automatically. You can verify it by typing:

sudo systemctl is-active libvirtd
active

To be able to create and manage virtual machines, you’ll need to add your user
to the “libvirt” and “kvm” groups. To do that, enter:

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

$USER is an environment variable that holds the name of the currently logged-in user.

Log out and log back in so that the group membership is refreshed.

Network Setup #

You can use the brctl tool to list the current bridges and the interfaces they are connected to:

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

The “virbr0” bridge does not have any physical interfaces added. “virbr0-nic” is a virtual device with no traffic routed through it. The sole purpose of this device is to avoid changing the MAC address of the “virbr0” bridge.

This network setup is suitable for most Ubuntu desktop users but has limitations. If you want to access the guests from outside the local network, you’ll need to create a new bridge
and configure it so that the guest machines can connect to the outside world through the host physical interface.

Creating Virtual Machines #

Now that KVM is installed on your Ubuntu desktop, you can create the first VM. This can be done either from the command-line or using the virt-manager application.

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

  1. In the Activities search bar type “Virtual Machine Manager” and click on the icon to launch the application.

  2. After the application is started, from the top menu click on “File” -> “New Virtual Machine”:

    New Virtual Machine
  3. A new window will appear. Choose “Local install media” and click on the “Forward” button.

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

  5. In the next screen, choose the VM’s memory and CPU settings. Click Forward.

  6. Next, select “Create a disk image for the virtual machine” and select the VM’s disk space size. Click Forward.

  7. Enter a name for your virtual machine name and click “Finish”.

  8. The VM will boot up, and a new window will open:

    Virtual Machine Install

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

Once the operating system has been installed, you can access the virtual machine from the virt-manager application, via ssh
or using the Serial Console
interface.

Conclusion #

We’ve shown you how to install KVM on Ubuntu 20.04 systems. You can now create your Windows or Linux guest machines. To find more information about KVM, visit the KVM documentation
page.

If you have any questions, please leave a comment below.

[ad_2]

Source link

Related Posts

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.