+3 votes
537 views
How to install KVM on Ubuntu 21.04

in Virtualization by (551k points)
reopened | 537 views

1 Answer

+4 votes
Best answer

1. How to install KVM on Ubuntu 21.04
2. Create virtual machine in Ubuntu 21.04 from Terminal
3 . Create virtual machine in Ubuntu 21.04 graphical mode

Virtualization has been developed in order to provide the user with a practical option to mount virtual machines with newly released operating systems or that are still in beta. With virtualization in Linux we can avoid that a real and productive environment is affected by changes or failures in these systems. In addition, when we create a virtual machine we do not use more resources than necessary and we can test systems such as Windows, Linux, Android or macOS even when the real system is not compatible. On Linux, embedded virtualization is made possible by KVM.

KVM (kernel-based Virtual Machine) is developed as an open source virtualization technology which is integrated into the operating system and thanks to it, Linux is allowed to work as a hypervisor, where the host machine can run isolated virtual environments. which are the virtual machines (VM).

KVM technology is capable of turning Linux into a type 1 hypervisor which does not require an operating system. We mentioned this since hypervisors need components based on the operating system to offer them to virtual machines (I / O components, device drivers,), so KVM already hosts these values ​​by being integrated directly with the Linux kernel .

To stay up to date, remember to subscribe to our YouTube channel!   SUBSCRIBE

TechnoWikis will explain how to install KVM in Ubuntu 21.04 and thus get the most out of this technology.

1. How to install KVM on Ubuntu 21.04

Step 1


The first thing is to know that we are working on Ubuntu 21.04, for this in the terminal we execute:

 lsb_release -a 

image

Step 2


Now we must check if Ubuntu 21.04 is compatible with KVM, we verify this with the following command:

 egrep -c '(vmx | svm)' / proc / cpuinfo 

Step 3


If the result is greater than zero (0), we can have KVM:

image

Step 4


Now we check that Ubuntu 21.04 can support KVM:

 sudo kvm-ok 

image

Step 5


When this error is generated, we must install the utility that does the correct analysis, we will execute:

 sudo apt install cpu-checker 

image

Step 6


We enter the letter S to confirm the download and installation of the utility:

image

Step 7


We check the support again. We see that it does support KVM.

 sudo kvm-ok 

image

Step 8


With this verified, we are going to install KVM and its dependencies with the following command:

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

image

Step 9


At the end of this process we will see the following:

image

Step 10


We have installed the following:

  • The qemu package (fast emulator), this is an application to enable hardware virtualization
  • The qemu-kvm package which is the main KVM package
  • The libvritd-daemon which is the virtualization daemon
  • The bridge-utils package with which we can establish the bridge connection so that other users have access to the virtual machine
  • The virt-manager with which we can manage virtual machines through the graphical user interface

Step 11


We check the status of the libvirt daemon:

 sudo systemctl status libvirtd 

image

Step 12


We enable it with the Ubuntu 21.04 boot:

 sudo systemctl enable --now libvirtd 

image

Step 13


We check that the KVM modules are running:

 lsmod | grep -l kvm 

image

Step 14


We are ready to create our virtual machine with KVM on Ubuntu 21.04. We can list all compatible systems and distributions with the following command:

 osinfo-query os 

image

To install the virtual machine we can use two methods, from the terminal or graphically.

2. Create virtual machine in Ubuntu 21.04 from Terminal

Step 1


For this process we will use the command "virt-install" in the following way:

 sudo virt-install --name = Debian --os-variant = debian10 --vcpu = 412 --ram = 2048 --graphics spice --location = /home/technowikis/Downloads/debian-10.6.0-amd64-netinst.iso --network bridge: enp0s3 

Step 2


In this case we define. This will create the virtual machine from terminal.

  • Name of the distribution or system
  • Version to use
  • Hardware parameters
  • Path where the ISO file is

image

3 . Create virtual machine in Ubuntu 21.04 graphical mode

Step 1


It is a more complete process, first of all, we install the required dependencies:

 sudo apt install uvtool 

image

Step 2


We enter the letter S to confirm the download:

image

Step 3


Once installed we execute the following to access the administrator:

 sudo virt-manager 

image

Step 4


To create the machine from here, go to the menu "File - New virtual machine":

image

Step 5


We establish the resource from where we will install:

image

Step 6


We click on Browse and choose the downloaded ISO image:

image

Step 7


We click on "Choose volume" and we will see this integrated path:

image

Step 8


We click on Forward and now we define memory and CPU:

image

Step 9


Click on Forward and we define the size of the virtual hard disk:

image

Step 10


Click Forward again and define the name of the virtual machine and select the network adapter to use for it:

image

Step 11


We click on Finish and the virtual machine creation process will proceed:

image

Step 12


When the machine completes automatically, it will start:

image

Step 13


KVM gives us different options to manage virtual machines:

image

Step 14


From the menu we control it:

image

We see how KVM is a comprehensive solution integrated into the operating system itself to work with virtual machines.


by (3.5m points)

Related questions

+5 votes
1 answer
asked Nov 11, 2020 in Virtualization by backtothefuture (551k points) | 265 views
+3 votes
1 answer
asked Nov 10, 2020 in Virtualization by backtothefuture (551k points) | 415 views
+5 votes
1 answer
asked Nov 10, 2020 in Virtualization by backtothefuture (551k points) | 400 views
+3 votes
1 answer
asked Nov 11, 2020 in Virtualization by backtothefuture (551k points) | 381 views
+5 votes
1 answer
asked Nov 10, 2020 in Virtualization by backtothefuture (551k points) | 427 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,633 questions
10,765 answers
510 comments
3 users