Changes

Created page with "{{#pagetitle: Creating KVM Virtual Machines on RHEL 8 using Cockpit and virt-manager }} <table border="0" cellspacing="0" width="100%"><tr> <td width="20%">Installing KVM Vi..."
{{#pagetitle: Creating KVM Virtual Machines on RHEL 8 using Cockpit and virt-manager }}
<table border="0" cellspacing="0" width="100%"><tr>
<td width="20%">[[Installing KVM Virtualization on RHEL|Previous]]<td align="center">[[Red Hat Enterprise Linux Essentials|Table of Contents]]<td width="20%" align="right">[[Creating KVM Virtual Machines on RHEL with virt-install and virsh|Next]]</td>
<tr>
<td width="20%">Installing KVM Virtualization on RHEL 8<td align="center"><td width="20%" align="right">Creating KVM Virtual Machines on RHEL 8 with virt-install and virsh</td>
</table>
<hr>


<htmlet>rhel8</htmlet>


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 with virt-install and virsh|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:

<pre>
# dnf install cockpit-machines
</pre>

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:


[[File: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:


[[File: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:


[[File: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:


[[File: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:

<pre>
# dnf install virt-viewer
</pre>

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

https://virt-manager.org/download/</span></a>

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:


[[File: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:

<pre>
# virt-viewer MyFedoraGuest
</pre>

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

<pre>
$ virt-viewer --connect qemu+ssh://&lt;user&gt;@&lt;host&gt;/system &lt;guest name&gt;
</pre>

For example:

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

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:


[[File: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:


[[File: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:


[[File: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:


[[File: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:


[[File: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 KVM Networked Bridge Interface|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:


[[File: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:


[[File: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.

== Summary ==

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.


<htmlet>rhel8</htmlet>


<hr>
<table border="0" cellspacing="0" width="100%"><tr>
<td width="20%">[[Installing KVM Virtualization on RHEL|Previous]]<td align="center">[[Red Hat Enterprise Linux Essentials|Table of Contents]]<td width="20%" align="right">[[Creating KVM Virtual Machines on RHEL with virt-install and virsh|Next]]</td>
<tr>
<td width="20%">Installing KVM Virtualization on RHEL 8<td align="center"><td width="20%" align="right">Creating KVM Virtual Machines on RHEL 8 with virt-install and virsh</td>
</table>