Creating KVM Virtual Machines on RHEL 8 using Cockpit and virt-manager

Revision as of 19:25, 10 June 2019 by Neil (Talk | contribs) (Starting the Installation)

Revision as of 19:25, 10 June 2019 by Neil (Talk | contribs) (Starting the Installation)

PreviousTable of ContentsNext
Installing KVM Virtualization on RHEL 8Creating KVM Virtual Machines on RHEL 8 with virt-install and virsh

You are reading a sample chapter from the Red Hat Enterprise Linux 8 (RHEL 8) Essentials book.

Purchase a full copy of Red Hat Enterprise Linux 8 (RHEL 8) Essentials in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book

KVM-based virtual machines can easily be configured on RHEL 8 using either the virt-manager is now deprecated in RHEL 8 with the intention that it will be fully replaced by the Cockpit module in the future. As of RHEL 8, however, virt-manager is still available and includes features not yet integrated into the Cockpit virtual machine module.

The command-line approach to virtual machine creation will be covered in the next chapter entitled Creating KVM Virtual Machines on RHEL 8 with virt-install and virsh.

Installing the Cockpit Virtual Machines Module

By default, the virtual machines module is not included in a standard Cockpit installation. Assuming that Cockpit is installed and configured, the virtual machines module may be installed as follows:

# dnf install cockpit-machines

Once installed, the Virtual Machines option (marked A in Figure 21-1) will appear in the navigation panel next time you log into the Cockpit interface:

Rhel 8 cockpit vm page.png

Figure 21-1

Creating a Virtual Machine in Cockpit

To create a virtual machine in Cockpit, simply click on the Create New VM button marked B in Figure 22-1 to display the creation dialog.

Within the dialog, enter a name for the machine and choose whether the installation media is in the form of an ISO accessible via a URL or a local filesystem path. Ideally, also select the vendor and operating system type information for the guest. While not essential, this will aid the system in optimizing the virtual machine for the guest.

Also specify the size of the virtual disk drive to be used for the operating system installation and the amount of memory to be allocated to the virtual machine:

Rhel 8 cockpit create vm.png

Figure 21-2

For this example, leave the Immediately Start VM option unselected and, once the new virtual machine has been configured, click on the Create button to build the virtual machine. After the creation process is complete, the new VM will appear in Cockpit as shown in Figure 21-3:

Rhel 8 cockpit vm created.png

Figure 21-3

Starting the Installation

To start the new virtual machine and begin installing the guest operating system from the designated installation media, click on the Install button highlighted in Figure 21-3 above. Cockpit will start the virtual machine and switch to the Consoles view where the guest OS screen will appear:

Rhel 8 cockpit vm console.png

Figure 21-4

To complete the installation, interact with the screen in the Consoles view just as you would if you were installing the operating system on physical hardware.

It is also possible to connect with and display the graphical console for the VM from outside the Cockpit browser session using the virt-viewer tool. To install virt-viewer on a RHEL 8 system, run the following command:

# dnf install virt-viewer

The virt-viewer tool is also available for Windows systems and can be downloaded from the following URL:

To connect with a virtual machine running on the local host, simply run virt-viewer and select the virtual machine to which you wish to connect from the resulting dialog:

Rhel 8 virt-viewer-select vm.png

Figure 21-5

Alternatively, it is also possible to specify the virtual machine name and bypass the selection dialog, for example:

# virt-viewer MyFedoraGuest

To connect a virt-viewer instance to a virtual machine running on a remote host using SSH, the following command can be used:

$ virt-viewer --connect qemu+ssh://<user>@<host>/system <guest name>

For example:

$ virt-viewer --connect qemu+ssh://[email protected]/system MyFedoraGuest

When using this technique it is important to note that you will be prompted twice for the user password before the connection will be fully established.

Once the virtual machine has been created, the Cockpit interface can be used to monitor the machine and perform tasks such as rebooting, shutting down or deleting the guest system. An option is also included on the Disks panel to add additional disks to the virtual machine configuration.

Creating a Virtual Machine using virt-manager

With the caveat that virt-manager is now deprecated and will be removed once the Virtual Machines Cockpit extension is fully implemented, the remainder of this chapter will explore the use of this tool to create new virtual machines.

Starting the Virtual Machine Manager

Begin by launching Virtual Machine Manager from the command-line in a terminal window by running virt-manager. Once loaded, the virtual machine manager will prompt for the password of the currently active user prior to displaying the following screen:

Rhel 8 virt-manager main.png

Figure 21-6

The main screen lists the current virtual machines running on the system. At this point there should only be one, the hypervisor running on the host system. By default the manager should be connected to the host. If it is not, connect to the host system by right-clicking on the entry in the list and selecting Connect from the popup menu.

To create a new virtual system, click on the new virtual machine button (the far left button on the toolbar) or right-click on the hypervisor entry and select New from the resulting menu to display the first screen of the New VM wizard. In the Name field enter a suitably descriptive name for the virtual system. On this screen, also select the location of the media from which the guest operating system will be installed. This can either be a CD or DVD drive, an ISO image file accessible to the local host, a network install using HTTP, FTP, NFS or PXE or the disk image from an existing virtual machine:

Rhel 8 virt-manager create vm.png

Figure 21-7

Configuring the KVM Virtual System

Clicking Forward will display a screen seeking additional information about the installation process. The screen displayed and information required will depend on selections made in the preceding screen. For example, if a CD, DVD or ISO was selected, this screen will ask for the specific location of the ISO file or physical media device. This screen also attempts to identify the type and version of the guest operating system to be installed (for example the Windows version or Linux distribution) based on the installation media specified. If it is unable to do so, uncheck the Automatically detect from installation media / source option, type in the first few character of the operating system name and select an option from the list of possible matches:

Rhel 8 virt-manager select os.png

Figure 21-8

Once these settings are complete, click the Forward button to configure CPU and memory settings. The optimal settings will depend on the number of CPUs and amount of physical memory present in the host together with the requirements of other applications and virtual machines that will run in parallel with the new virtual machine:

Rhel virt-manager new vm memory.png

Figure 21-9

The last item to configure before creating the virtual machine is the storage space for the guest operating system and corresponding user data. This takes the form of a virtual disk image or pre-existing storage. A virtual disk drive is essentially an image file located on the file system of the host computer which is seen by the virtual machine as a physical disk drive.

Options are available to create an image disk of a specified size, select a pre-existing volume or to create a storage volume of a specified format (raw, vmdk, ISO etc). Unless you have a specific need to use a particular format (for example you might need to use vmdk to migrate to a VMware based virtualization environment at a later date) or need to use a dedicated disk or partition, it is generally adequate to simply specify a size on this screen:

Rhel 8 virt-manager vm storage.png

Figure 21-10

Once these settings are configured, click the Forward button once more. The final screen displays a summary of the configuration. Review the information displayed. Advanced options are also available to change the virtual network configuration for the guest, a topic that will be covered in the chapter entitled Creating a RHEL 8 KVM Networked Bridge Interface.

Starting the KVM Virtual Machine

Click on the Finish button to begin the creation process. The virtualization manager will create the disk and configure the virtual machine before starting the guest system. The new virtual machine will appear in the main virt-manager window with the status set to Running as illustrated in Figure 21-11:

Rhel 8 virt-manager vm running.png

Figure 21-11

By default, the console for the virtual machine should appear in the virtual machine viewer window. To view the console of the running machine at any future time, ensure that it is selected in the virtual machine list and select the Open button from the toolbar. The virtual machine viewer should be ready for the installation process to begin:

Rhel 8 virt-manager viewer.png

Figure 21-12

From this point on, simply follow the operating system installation instructions to install the guest OS in the KVM virtual machine.


This chapter has outlined two different ways to create new KVM-based virtual machines on a RHEL 8 host system. The first option covered involves the use of the Cockpit web-based interface to create and manage virtual machines. This has the advantage of not requiring access to a desktop environment running on the host system. An alternative option is to use the virt-manager graphical tool. Though deprecated in RHEL 8.0 and likely to be removed in later releases, virt-manager currently provides options not currently available in the Cockpit Virtual Machines extension. At that the point that virt-manager is removed it is expected that Cockpit will provide equal or better functionality.

With these basics covered, the next chapter will cover the creation of virtual machines from the command-line.

You are reading a sample chapter from the Red Hat Enterprise Linux 8 (RHEL 8) Essentials book.

Purchase a full copy of Red Hat Enterprise Linux 8 (RHEL 8) Essentials in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book

PreviousTable of ContentsNext
Installing KVM Virtualization on RHEL 8Creating KVM Virtual Machines on RHEL 8 with virt-install and virsh