Bookmark this page

Creating a Linux Virtual Machine

Objective

After completing this section, students should be able to use the Administration Portal to manually create a RHEL virtual machine running in the Red Hat Virtualization environment.

Installing Console Components on Client Systems

Creating and managing a virtual machine requires occasional console access, especially during manual installations when console access is necessary to interact with the installation program's prompts. Virtual machines are configured to use either the SPICE or VNC protocols to manage remote connections. On the client systems from which you will access the virtual machines, you will install the Remote Viewer.

Remote Viewer for Red Hat Enterprise Linux

The Remote Viewer application provides users with a graphical console for connecting to virtual machines. Once installed, it is called automatically when opening a SPICE session with a virtual machine. Alternatively, it can also be used as a standalone application. Remote Viewer is included in the virt-viewer package provided in the RHEL BaseOS repository. The spice-xpi Firefox plug-in is no longer required, since the external Remote Viewer application makes the connection.

Install the virt-viewer package on the system from which you access the Application Portal or the VM Portal. No browser restart is required, since no browser plugin is being installed.

[root@client ~]# yum -y install virt-viewer

Remote Viewer for Microsoft Windows

Remote Viewer for Microsoft Windows is available as a download from your RHV Manager system, with a 32-bit and a 64-bit version of the virt-viewer installer. Download the architecture of your choice, double-click the file, and answer the security warning and User Account Control prompts to complete the install.

  • https://your-manager-fqdn/ovirt-engine/services/files/spice/virt-viewer-x86.msi (32-bit)

  • (64-bit Windows) https://your-manager-fqdn/ovirt-engine/services/files/spice/virt-viewer-x64.msi (64-bit)

The usbdk driver is also available for installation on Windows clients. usbdk enables remote viewer exclusive access to USB devices on Windows. Installing usbdk requires Administrator privileges.

  • https://your-manager-fqdn/ovirt-engine/services/files/spice/usbdk-x86.msi (32-bit)

  • https://your-manager-fqdn/ovirt-engine/services/files/spice/usbdk-x64.msi (64-bit)

Creating a New Virtual Machine

To create a new virtual machine from the Administration Portal, click open the ComputeVirtual Machines menu and click the New button to provision a new virtual machine. The New Virtual Machine form defines the basic virtual machine parameters.

Virtual Machine Build Parameters

The top of the form defines that parameters necessary for RHV to provision resources. Choose the data center and cluster in which to deploy the new virtual machine. When deploying from prebuilt images, choose an existing template to use, which avoids performing an installation.

Figure 2.14: New Virtual Machine Window

Select the correct operating system and the sizing profile, which are predefined and customizable. You have three choices for optimizing the virtual machine build:

Desktop

  • Enable all USB devices

  • Enable the Smart Card device

  • Use an Image with Thin Allocation

  • Instance is Stateless

Server

  • Disable the Sound Card device

  • Use a Cloned Disk Image

  • Instance is Not Stateless

High Performance

  • Enable Headless Mode and enable Serial console

  • Disable all USB devices

  • Disable the Sound Card device

  • Disable the Smart Card device

  • Enable Pass-Through Host CPU

  • Disable VM migration

  • Enable IO Threads, Num Of IO Threads = 1

  • Disable the Memory Balloon Device

  • Enable High availability only for pinned hosts

  • Disable the Watchdog device

  • Enable paravirtualized Random Number Generator PCI (virtio-rng) device

  • Enable Multi Queues per Virtual Interface

  • Set the IO and Emulator threads pinning topology

In the middle of the New Virtual Machine window, specify a unique name, description and comment that will assist administrators in identifying this system among all those in production. The Instance Images options determine the system disk source, discussed below.

Near the bottom of the window, specify an existing logical network to connect to this virtual machine's NIC. Additional NICs can be created now or added after the machine has been built.

Virtual Machine Disk Selection

An instance can be deployed or cloned from an existing template or disk, booted from a stored disk image, or created on a new disk with an operating system installation. Using templates, and booting from stored disks, is covered later in this course. For this new installation example, the virtual machine will need a new, blank disk, selected by clicking the Create button.

Figure 2.15: New Virtual Disk Window

Enter the Size (GiB) in gibibytes. The Alias is auto-generated by adding "_Disk" and a sequence number to your virtual machine name. A Description is not required, but is helpful when locating disks stored in a data domain when not currently attached to virtual machines.

You have a choice for Interface, indicating the disk controller protocol to use:

IDE

The oldest and slowest, but also the most compatible with older operating systems and disks. This selection is not recommended for performance.

VirtIO

Will be created as a /dev/vdX device. This driver is much faster than IDE, but has been surpassed in capabilities by the VirtIO-SCSI driver. VirtIO is recommended if advanced features are not needed, handling at most 25-30 devices due with one device per controller.

VirtIO-SCSI

Will be created as a /dev/sdX device. The Virtio-SCSI driver significantly improves scalability compared to the virtio-blk driver it replaces. VirtIO-SCSI can connect directly to SCSI LUNs, and handles hundreds of devices on a single controller.

The Storage Domain stores this disk image and the virtual machine will boot from that stored image. The data domains listed are those attached to the cluster you specified earlier.

The Allocation Policy provides a choice of thick or thin provisioning.

Pre-allocated (thick)

Provisions the full disk storage capacity when the disk is created. Space allocated to this disk is not available for any other use by the data store and other virtual machines. The performance of pre-allocated disks is higher, because write requests are not delayed by space extension requests.

Thin provisioned (sparse)

Allocates only the initial required space, and adds space allocations as disk use grows. Thin-provisioned disks are created faster and use less storage space. Ongoing performance can be slower, because space allocations must be zeroed before data blocks can be used.

A Disk Profile defines the maximum level of I/O transactions and throughput for a virtual disk. Disk profiles are created based on storage profiles defined under data centers, and must be manually assigned to individual virtual disks for the profile to take effect. There is currently only one disk profile to select for the hosted_storage data domain.

Click the OK button to create this virtual disk and return to the New Virtual Machine window. Again click the OK button to close the New Virtual Machine dialog and create the virtual machine. The machine lists in the Virtual Machines table with a status of Down. Because this virtual machine's new system disk is empty, the next task is to perform an installation to the disk.

Booting the Virtual Machine

Now that the new virtual machine is configured, it is time to install an operating system. If the virtual machine started normally, it would default to booting from the empty disk. Instead, we will create a temporary (Run Once) set of parameters to start from a RHEL boot ISO.

Understanding Run Once

There are two options on the Run button: Run and Run Once. Run will start a virtual machine using the default boot configuration. Run Once presents a window for entering temporary boot parameters that will be used only once and discarded.

However, Run Once understands that installations typically require at least one reboot before finishing. To discard Run Once, the virtual machine must be shut down, not rebooted, and an operator must select Run to initiate a normal boot. This explains why installation failures that reboot without a shutdown will continue to boot using Run Once parameters. Run Once settings are discarded when the virtual machine is shut down.

Select the new virtual machine in the Virtual Machines window. In the Run drop down menu select Run Once. This opens the Run Virtual Machine(s) window. Click the the + button next to Boot Options to open the Boot Options screen.

Figure 2.16: Run Virtual Machine(s) Boot Options

Virtual machines can be installed with the same methods used to install RHEL on physical systems:

Full RHEL DVD installation

The RHEL DVD ISO image is uploaded and stored in the data domain. The full ISO is attached as a virtual CD-ROM and the system boots to that CD-ROM to start a manual, interactive installation. The installation can be automated by specifying a Kickstart file location as a kernel boot parameter. The required BaseOS repository is on the Full DVD, and no network installation server is required.

RHEL Boot DVD ISO network installation

The RHEL Boot DVD ISO image is uploaded and stored in the data domain. The boot ISO is attached as a virtual CD-ROM and the system boots to that CD-ROM to start a manual, interactive installation. The installation can be automated by specifying a Kickstart file location as a kernel boot parameter. The Kickstart must specify an accessible network installation server URL to provide the BaseOS repository.

PXE network installation

Starting a network installation without a CD-ROM requires a PXE compliant network card. The NIC initiates a PXE-initiated installation from a network installation server URL, located using DHCP options. Network installations can also be interactive, but usually are automated with a Kickstart file store and found automatically on the network installation server.

Boot Options

In the Boot Options screen, enable the Attach CD checkbox. The drop-down field to the right lists all media images that have been loaded into this cluster's data domain. In this classroom, it is expected to default to the RHEL 8 boot ISO named rhel-8.0-x86_64-boot.iso.

In this classroom installation example, we chose the 550MB boot ISO option, to avoid downloading and storing the 8GB RHEL 8 DVD in the classroom data stores, and to provide an opportunity to practice a CDROM install with a manually entered Kickstart file boot parameter.

In the Predefined Boot Sequence: box, select the CD-ROM to highlight it, then use the Up button to move the CD-ROM to the top of the list. The virtual machine will now boot from that ISO.

Important

Clicking the OK button now would start the virtual machine and its installation. Because this installation method requires adding a Kickstart file kernel parameter, you need to access the virtual machine's console quickly, before the boot menu times out. Console access requires that you have installed the Remote Viewer. Verify the Remote Viewer installation before returning to the Boot Options screen.

Connecting to the Virtual Machine Console

To connect to the virtual machine's console, select the virtual machine row in the Virtual Machines table. When a virtual machine row is selected, the Console button will become available. Either click the Console button or right-click a virtual machine row and choose Console from the context menu. As observed below, the virtual machine is configure for SPICE functionality by default.

Figure 2.17: Run Virtual Machine(s) Console Settings

The Remote Viewer Connection File

When a virtual machine console is requested, a virt-viewer connection parameters file (console.vv) is sent to your browser. The first time you open a console connection, be sure to enable the Do this automatically for files like this from now on. so that your browser stores the application action for Remote Viewer files.

Figure 2.18: Opening a Remote Viewer File

The console.vv contains secure one-time connection information, including secure keys for connection encryption. An example file is displayed below.

[user@demo ~]$ cat console.vv
[virt-viewer]
type=spice
host=172.25.250.10
port=5900
password=onvRPyH3O9Hi
# Password is valid for 120 seconds.
delete-this-file=1
fullscreen=0
title=HostedEngine:%d
toggle-fullscreen=shift+f11
release-cursor=shift+f12
secure-attention=ctrl+alt+end
tls-port=5901
enable-smartcard=0
enable-usb-autoshare=1
usb-filter=-1,-1,-1,-1,0
tls-ciphers=DEFAULT
host-subject=O=lab.example.com,CN=hosta.lab.example.com
ca=-----BEGIN CERTIFICATE-----
...output omitted...

Adding the Kickstart File Kernel Parameter

When the Remote Viewer connection has been made, the virtual machine's console opens. The RHEL boot ISO will have booted, and presents an installation menu. Use your keyboard arrow keys to highlight Install Red Hat Enterprise Linux 8.0.0. When the line is selected, all that line's text will be white. With the line selected, hit your Tab key once, which causes the kernel booting parameters to display. Here is where you add the syntax (init.ks=Kickstart_file_URL) to locate the Kickstart file, as in the example below.

Figure 2.19: RHEL boot ISO menu with Kickstart Kernel Parameter

After entering the kernel parameters, press Enter to start the installation. Wait for the installation to complete. The virtual machine in the Virtual Machines table will change to an UP status..

Controlling Virtual Machines

Starting Virtual Machines

To start a virtual machine currently down, navigate to ComputeVirtual Machines. To start the virtual machine with its normal configuration, click the Run icon or right-click the virtual machine and select Run from the menu.

To start a virtual machine with non-default settings, select Run Once from the Run button pull-down to display the Run Virtual Machine(s) window.

Stopping Virtual Machines

There are three options to shut down a virtual machine:

  • Shut down the virtual machine directly using operating system commands. For example, shut down a RHEL virtual machine by logging in and running poweroff.

  • In the Virtual Machines table, right-click the virtual machine name and select Shutdown from the context menu. A virtual ACPI power button event is to the virtual machine. In some case, the guest operating system may ignore this event (for example, when Microsoft Windows 7 is displaying a login screen).

  • In the Virtual Machines table, right-click the virtual machine name and select Power Off from the context menu. This causes an ungraceful shutdown, similar to losing power. Use this method as a last resort, since pending file writes will be lost and data corruption could occur.

Suspending Virtual Machines

In the Virtual Machines table, select the virtual machine name and click the Suspend button (crescent moon icon.) A suspended virtual machine is put into Hibernate mode. The virtual machine's memory and CPU state are saved to disk and the machine stops processing.

To resume a suspended virtual machine, right-click the virtual machine and select Run from the menu.

Removing Virtual Machines

To remove a virtual machine, shut it down gracefully, then right-click the virtual machine and select Remove from the context menu. Click OK in the confirmation dialog box to confirm removing the virtual machine.

Warning

When removing a virtual machine, all resources associated with the virtual machine are deleted, including all virtual disks and virtual network cards. When a virtual disk is removed, the disk and its contents are erased permanently, as a security feature.

References

Further information is available in the Installing Linux Virtual Machines chapter of the Virtual Machine Management Guide for Red Hat Virtualization 4.3 at https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.3/html-single/virtual_machine_management_guide/index

Revision: rh318-4.3-c05018e