How to install KVM on Ubuntu 20.04

KVM is an open source virtualization technology built into the Linux kernel. It allows you to run multiple isolated client virtual mach...


KVM is an open source virtualization technology built into the Linux kernel. It allows you to run multiple isolated client virtual machines based on Linux or Windows. Each client machine 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 that will be used as development environments for different applications.

1. Prerequisites

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

Before proceeding with the installation, make sure 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 vendor 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

After the installation is complete, check that your system can run the 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 is dependent on your motherboard and processor type. Configure your system BIOS according to your motherboard's documentation.

2. 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 program that provides hardware emulation for KVM hypervisors
  • libvirt-daemon-system - configuration file for running the libvirt daemon as a system service
  • libvirt-clients - software used to manage the virtualization platform
  • bridge-utils - Command line tool for configuring network bridges
  • virtinst - command - line tool for creating virtual machines
  • virt-manager - provides an easy-to-use graphical interface and supports command-line tools for managing virtual machines through libvirt

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 that remembers the name of the currently logged-in user.

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

3. Network Setup

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

Run the brctl utility to list the current bridges and the interfaces they connect to.

brctl show

Output:

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

"virbr0" bridge does not have any physical interfaces added to it. The "virbr0-nic" is a virtual device that does not have any traffic passing through it. 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.

4. Creating a Virtual Machine

Now that KVM is installed on your Ubuntu desktop, let's go ahead and create our first virtual machine together. We can do this from the command line or by 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. Type "Virtual Machine Manager" in the search bar and click on the icon to launch the application.
  2. After the application starts, click on "File" -> "New Virtual Machine" from the top menu:
  3. A new window will be displayed. Select "Local install media" and click on the "Forward" button.
  4. Provide the path to your ISO image and click the Forward button.
  5. On the next screen, select the memory and CPU settings for the VM. Click Forward.
  6. Next, select "Create a disk image for the virtual machine" and choose the disk space size for the virtual machine. Click Forward.
  7. Enter the name of your virtual machine and click "Finish".
  8. The virtual machine will start and a new window will open.

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

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

5. Summary

We showed you how to install KVM on an Ubuntu 20.04 system, and now you can create Windows or Linux clients.

COMMENTS

Name

2023,2,Ai,2,AlmaLinux 9,3,Amazon Linux,5,Apache Web Server,1,AppImage,1,Arduino IDE,1,Artificial Intelligence,2,BalenaEtcher,1,Bitcoin,1,Blockchain Data,1,Bookworm,2,Bootable USB,1,C++,1,centos,1,CentOS 8,1,CentOS Stream,1,CMake,1,CockroachDB,2,cuDNN,1,Database Security,1,Debian,2,Debian 10,2,Debian 11,2,Debian 12,9,DNS,1,Docker,1,E-commerce,1,Fail2ban,1,Fedora Linux,1,Firefox 118,1,FreeIPA Server,1,Function,1,Game Projects,1,Git,3,Google PageSpeed,1,How to,5,How to Install,9,HTTPS,1,Introduction,1,Iptables,1,ISO Image,1,KVM,1,Laravel,1,Let's Encrypt SSL,1,Linux,4,Linux 6.4,1,Linux Kernel 6.5,1,Linux Mint,1,Linux Server,1,Linux-Based Systems,1,Mageia 9,1,Magento,1,MariaDB,1,Media Server,1,ModSecurity,1,New Features,1,Nextcloud,2,NGINX,2,Nvidia CUDA,1,odoo,1,Oracles,1,Performance,1,PHP Zip Module,1,pip,1,Plex,1,Port Forwarding,1,postgresql,2,Privacy,1,Programming,1,Pylint,1,python,5,Python 3.10,2,Quantum,1,Quantum Computers,1,Remote Branch,1,Renew,1,RHEL,1,Rocky Linux 9,2,Rufus,1,Shadow Password,1,SQLite,1,SSH,1,SSH key,1,SSH Keys,1,Step-by-Step,4,SuiteCRM,1,SUSE Linux,1,Syslog,1,System,1,Testing,1,Top 10,1,Translation,1,Ubuntu,1,Ubuntu 18.04,1,Ubuntu 20.04,5,Ubuntu 22.10,1,Ubuntu 23.04,1,Ubuntu Server,1,Ubuntu Upgrade,1,unsupported,1,Up-to-Date,1,Upgrade,1,Visual Studio Code,1,Vivaldi 6.2,1,Web 3.0,1,Web Hosting Security,1,Web Security,1,Webmin,1,What's New,1,Windows 11,1,
ltr
item
Linux code EDU: How to install KVM on Ubuntu 20.04
How to install KVM on Ubuntu 20.04
https://blogger.googleusercontent.com/img/a/AVvXsEgsOD7tUDmR1i_pYHyC3jXmX5RxA_mN61DdKeK0CGIpZGYMZqDQD4DqWqUH1A-PNs_jOaUJsMm3tq3dZmFe7LRf8pOUe8xilC6F9fUn48KzFZ23EpKsqOJ9iRg64cMcbUe1uB3B26Ax4Os819_9aIBGBlWY4PR_Hpi5fansT1Ntl2R8ELXhZ2PSt_ShmQ=w640-h398
https://blogger.googleusercontent.com/img/a/AVvXsEgsOD7tUDmR1i_pYHyC3jXmX5RxA_mN61DdKeK0CGIpZGYMZqDQD4DqWqUH1A-PNs_jOaUJsMm3tq3dZmFe7LRf8pOUe8xilC6F9fUn48KzFZ23EpKsqOJ9iRg64cMcbUe1uB3B26Ax4Os819_9aIBGBlWY4PR_Hpi5fansT1Ntl2R8ELXhZ2PSt_ShmQ=s72-w640-c-h398
Linux code EDU
https://linuxcodeedu.blogspot.com/2021/07/how-to-install-kvm-on-ubuntu-2004.html
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/2021/07/how-to-install-kvm-on-ubuntu-2004.html
true
6096992636254302192
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content