Create KVM virtual machine | virt-manager | RHEL CentOS 8

In this article I will share step by step instructions with screenshots to create KVM virtual machine using virt-manager (Virtual Machine Manager) in RHEL/CentOS 7/8
 

 
You can use the following GUIs to manage virtualization in RHEL/CentOS 8:

  • The RHEL/CentOS 8 web console, also known as Cockpit, provides a remotely accessible and easy to use graphical user interface for managing VMs and virtualization hosts.
  • The Virtual Machine Manager (virt-manager) application provides a specialised GUI for managing VMs and virtualization hosts.
IMPORTANT NOTE:

With RHEL/CentOS 8, virt-manager has been deprecated. The Cockpit web console is intended to become its replacement in a subsequent release. It is, therefore, recommended that you get familiar with the web console for managing virtualization in a GUI.

 

Pre-requisite

As a pre-requisite, you must first install KVM and enable KVM Virtualization on your Linux server host before you can create KVM Virtual Machine using virt-manager or any other method in RHEL/CentOS 8 Linux

 

Overview on Virtual Manager

  • The virt-manager application is a Python-based desktop user interface for managing virtual machines through libvirt.
  • It primarily targets KVM VMs, but also manages Xen and LXC (Linux containers) among others.
  • virt-manager displays a summary view of running VMs, supplying their performance and resource utilization statistics.
  • Using the virt-manager graphical interface, one can easily create new VMs, monitor them, and make configuration changes when required.

 

Install virt-manager

Virtual Machine Manager is not installed by default. Although if you have installed your Linux server using "Virtualization" then Virtual Machine Manager will be installed by default
To install virt-manager you can use DNF or YUM. I hope you are aware of DNF which is an alternative of YUM

[root@rhel-8 ~]# dnf install -y virt-manager
NOTE:

Graphical Environment is mandatory to access Virtual Manager. You can install GNOME Desktop Environment on your existing Linux server using DNF or YUM to create KVM virtual machine using virt-manager

 

Connection Details

Login to you graphical console
Execute virt-manager from the terminal as root user (if you are using normal user, then the command will prompt for root password)

Click on EditConnection Details

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Virtual Networks

Click on EditVirtual Networks

By default once you install Virtualization related package, a bridge interface virbr0 with NAT is created on the Linux server. This will be visible under "Virtual Networks" TAB

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

The same virtual network can also be checked using nmcli command

[root@rhel-8 ~]# nmcli con show --active
NAME    UUID                                  TYPE      DEVICE
br0     4a38747e-49f4-4213-83cb-a946d3dffefb  bridge    nm-bridge
virbr0  3169c22f-6e1b-47df-9e07-6a4318e720b3  bridge    virbr0
slave1  eb862842-ba6a-47fe-994c-733977a8275b  ethernet  eno49
slave2  631e5c3e-bf2f-46d3-b9dd-dca2001f586b  ethernet  eno50
vnet0   3d1aacbe-0e20-45b6-8305-000525f28bfa  tun       vnet0
vnet1   c8b0cc12-d9cf-4c56-a9e1-b300b714738f  tun       vnet1
vnet2   4506cb41-4333-4ac8-a116-4f50a24bfec8  tun       vnet2
vnet3   9cd7bcd6-cc53-447a-aaa9-009fbed0d322  tun       vnet3

Using the Virtual Networks tab you will be able to configure the following types of virtual network:

  • NATed
  • Routed
  • Isolated

Default Network

  • The default network is a NAT-based virtual network.
  • It allows virtual machines to communicate with the outside networks irrespective of the active network interface (Ethernet, wireless, VPN, and so on) available on the hypervisor.
  • It also provides a private network with IP and a DHCP server so that the VMs will get their IP addresses automatically.
  • Virtual network configuration files are stored in /etc/libvirt/qemu/networks/ as XML files.
  • For the default network it is /etc/libvirt/qemu/networks/default.xml.
[root@rhel-8 ~]# virsh net-info default
Name:           default
UUID:           836520d9-fb0a-46f0-8745-033353151e93
Active:         yes
Persistent:     yes
Autostart:      yes
Bridge:         virbr0

 

Storage

  • The Storage tab provides details of the storage pools available.
  • A storage pool is just a store for saved virtual machine disk images.
  • At the time of writing, libvirt supports creating storage pools from the different types of source shown in the following screenshot; directory and LVM are the most commonly used.
  • Default storage pool: Default is the name of file-based storage pool that libvirt created to store its virtual machine image file. The location of this storage pool is in /var/lib/libvirt/images.

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Create KVM Virtual Machine using virt-manager

The following methods are available with virt-manager for Guest OS installation:

  • Local installation media (ISO Image or CD-ROM)
  • Network installation (HTTP, FTP, or NFS)
  • Network boot (PXE)
  • Importing existing disk images

 

Create new Virtual Machine

From Virtual Machine Manager, click on FileNew Virtual Machine to Create to open the wizard to create KVM Virtual Machine using virt-manager

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

The wizard breaks down the virtual machine creation process into five steps:

  • Choosing the installation method.
  • Configuring the installation media.
  • Memory and CPU configuration.
  • Virtual machine storage configuration.
  • Naming the Guest OS and networking configuration.

 

Select Installation Media

Select Local install media (ISO Image or CDROM) and click on the Forward button.

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Clicking on the Forward button will take you to Step 2 where you have to specify the ISO image location.

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Select your ISO which you plan to use to create KVM Virtual Machine using virt-manager

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

virt-manager automatically detects the operating system based on the install media. It uses the OS information database provided by libosinfo.
At the time of writing this article, CentOS 8 was not part of Virtual Manager
Un-check the option to "automatically detect from the installation media/source" if the Virtual Manager fails to get the source information and choose Generic (default)

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Define CPU and Memory for VM

On the next screen, specify the memory and CPU that you want allocate for the virtual machine:

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Define Storage for VM

  • The wizard shows the maximum amount of CPUs and memory you can allocate. Configure these settings and click Forward to configure storage for the virtual machine:
  • Make sure you assign sufficient space for your virtual machine.
  • By default, it creates a virtual disk at the /var/lib/libvirt/qemu location, which is the default pool.
  • If there are any other custom storage pools defined on the system, select create custom storage and either directly enter the path of the disk or click on the Manage button, which will open the Locate or create storage volume dialog box where you can select an existing volume or create a new one from the defined storage pool, if any available.

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Assign Guest VM Name and Configure Network

  • The next and final step is naming the guest and networking configuration.
  • The default machine name is based on the selected OS. But since I am using generic Default, the name is not populated automatically. I will change it to vm_1.
  • You can change it to whatever name you want to give but note that only underscores (_), periods (.), and hyphens (-) are supported:

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

If you wish to further configure the virtual machine's hardware first, check the Customize configuration before install box first before clicking Finish. Or you can click on the bulb icon (as shown below) to open the configuration wizard for respective VM

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Access and Modify VM Configuration

Below is a sample screenshot of VM Setting's section

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Create VM Snapshot in Virtual manager

  • You can also create snapshots in Virtual Manager.
  • Select the VM for which you wish to create snapshot
  • Click on Snapshot icon. Follow the below screenshot
  • Click on + sign to take snapshot of the current state of the VM

Create KVM virtual machine | virt-manager | RHEL/CentOS 7/8

 

Lastly I hope the steps from the article to create KVM Virtual Machine using Virtual Manager on Linux was helpful. So, let me know your suggestions and feedback using the comment section.

 

References:
Create KVM Virtual Machine using Virtual Manager

Leave a Comment

Please use shortcodes <pre class=comments>your code</pre> for syntax highlighting when adding code.