Virtual Machines
Oracle Linux Virtualization Manager lets create virtual machines as well as perform basic administration tasks such as live editing, live migration, and creating and using templates and snapshots.
Creating a New Virtual Machine
This section shows you how to install a remove viewer, create Oracle Linux or Microsoft Windows virtual machines, and install the respective guest OS, agents and drivers.
For detailed information on the supported guest operating systems, see the Oracle® Linux: KVM User's Guide.
Before creating Microsoft Windows virtual machines, ensure the following prerequisites are met.
Obtain the Oracle VirtIO Drivers for Microsoft Windows.
- Download Oracle VirtIO Drivers for Microsoft Windows to the Manager host from Oracle Software Delivery Cloud or My Oracle Support (MOS). Refer to Oracle VirtIO Drivers for Microsoft Windows for Use With KVM for more information.
- Upload the Oracle VirtIO Drivers for Microsoft Windows ISO image to an Oracle Linux Virtualization Manager storage domain. Refer to Uploading an ISO Image to the Data Domain for more information.
Download the QEMU guest agent to the Manager host.
- For ULN registered hosts or using Oracle Linux Manager, download
qemu-ga-win
from the oVirt Release 4.5 on Oracle Linux 8 (x86_64) - Extra channel. - For Oracle Linux yum server configured KVM hosts, download
qemu-ga-win
from the Oracle Linux 8 (x86_64) oVirt 4.5 Extra repository.
Note:
In addition to creating virtual machines, you can import an Open Virtual Appliance (OVA) file into your environment from any host in the data center. For more information, see oVirt Virtual Machine Management in oVirt Documentation.
Installing Remote Viewer on Client Machine
A console is a UI that allows you to view and interact with a virtual machine similar to a physical machine. The default console is a Remote Viewer application that provides users with a UI for connecting to virtual machines.
Before you begin a Linux or Windows OS installation, download the appropriate install package from the Virtual Machine Manager web site.
Note:
See See Windows Virtual Machines Lose Functionality Due To Deprecated Guest Agent in the Known Issues section of the Oracle Linux Virtualization Manager: Release Notes.For more information, see Consoles in the Oracle Linux Virtualization Manager: Architecture and Planning Guide.
To install Remote Viewer on Linux:
-
Ensure you have downloaded the
virt-viewer
installation package. -
Install the
virt-viewer
package using one of the following commands depending on your system.# yum install virt-viewer
# dnf install virt-viewer
-
Restart your browser for the changes to take effect in the Oracle Linux Virtualization Manager.
You can now connect to your virtual machines using the VNC protocol.
To install Remote Viewer on Windows:
-
Ensure you have downloaded either the 32-bit or 64-bit
virt-viewer
installer depending on the architecture of your system. -
Go to the folder where you saved the file and double-click the file.
-
If prompted with a security warning, click Run.
-
If prompted by User Account Control, click Yes.
Once installed, you can access Remote Viewer in the VirtViewer folder of All Programs from the Start menu.
Creating a New Linux or Microsoft Windows Virtual Machine
Follow this general procedure to create a new virtual machine:
-
Go to Compute and then click Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Click New.
The New Virtual Machine dialog box opens with the General tab selected on the sidebar.
-
From the Cluster drop-down list, select the data center and host cluster for the new host.
The Default data center is pre-selected in the drop-down list.
For the procedures to create new data centers or a new clusters, refer to Data Centers or Clusters tasks.
-
From the Operating System drop-down list, select the operating system for the virtual machine.
- Using the Optimized for dropdown list, select the type of system for which the
virtual machine will be optimized.
- Server (default) - have no sound card, use a cloned disk image, and are not stateless
- Desktop - have a sound card, use an image (thin allocation), and are stateless
- High Performance - have a number of configuration changes; see Optimizing Clusters, Hosts and Virtual Machines.
-
For the Name field, enter a name for the new virtual machine.
-
Under Instance Images, add storage to the virtual machine by either using an existing virtual disk or creating a new virtual desk.
-
To use an existing virtual disk, click Attach and select the virtual disk to use for the virtual machine storage. Then click OK.
-
To create a new virtual disk, click Create and update the fields for the virtual machine storage or accept the default settings. Then click OK.
If you are creating a new virtual disk, the following fields are key:
-
Check Bootable.
-
Enter a disk Size (GiB).
-
From the Interface drop-down list, select VirtIO-SCSI.
-
From the Allocation Policy drop-down list, selecting Preallocated reserves the disk space, while selecting Thin Provision creates a sparse allocated virtual disk.
- From the Disk Profile list, select the storage domain where you can save the virtual disk.
Note:
Repeat this step if you need to create additional virtual disks. -
-
Connect the virtual machine to a network by adding a network interface.
See Creating a Logical Network, Assigning a Logical Network to a KVM Host, and Customizing vNIC Profiles for Virtual Machines.
-
Click Show Advanced Options to display additional configuration options available for the new virtual machine.
-
(Optional) Click the System tab on the sidebar to adjust the CPU and memory size for the virtual machine from the defaults.
-
For Memory Size field, the default value is
1024 MB
. -
For the Maximum memory field, the default value is
4096 MB
, which is four times the memory size but can be manually configured. -
For the Total Virtual CPUs field, the default value is
1
.
Note:
Depending on the operating system you are installing, there might be memory and vCPU requirements. -
-
Click OK to create the virtual machine.
-
Proceed to Installing the Oracle Linux Guest OS or Installing the Microsoft Windows Guest OS.
Installing the Oracle Linux Guest OS
To install the Oracle Linux guest OS:
-
From the Virtual Machines pane, select the Oracle Linux virtual machine created in Creating a New Linux or Microsoft Windows Virtual Machine.
-
Using the down arrow next to Run, select Run Once.
- Attach your ISO file, for example OracleLinux-R7-U6-Server-x86_64-dvd.iso, and click OK.
-
Click Console to open a console to the virtual machine.
If you have not installed the Remote Viewer application, refer to Installing Remote Viewer on Client Machine.
-
Install the Oracle Linux guest OS.
Refer to the Oracle® Linux documentation for more information on how to install Oracle Linux.
- When the installation completes, reboot the virtual machine.
-
(Optional) If you use a proxy server for Internet access, configure Yum with the proxy server settings. For more information about configuring
firewalld
, see Configuring Packet-filtering Firewalls in the Oracle® Linux 7: Security Guide or Oracle Linux 8: Configuring the Firewall -
(Optional) If you are using yum to update the host, make sure the host is using the modular yum repository configuration. For more information, see Getting Started with Oracle Linux Yum Server.
-
Proceed to Installing the Oracle Linux Guest Agent.
Installing the Oracle Linux Guest Agent
To install the Oracle Linux guest agent, follow the appropriate steps for your version.
-
Open a console session for the Oracle Linux guest and log in to the terminal.
-
Install the latest guest agent package.
For Oracle Linux 8 guests:
# dnf module reset virt # dnf config-manager --enable ol8_kvm_appstream # dnf -y module enable virt:kvm_utils3 # dnf -y install qemu-guest-agent
For Oracle Linux 7 guests:
# yum install yum-utils -y # yum-config-manager --enable ol7_latest # yum install qemu-guest-agent
For Oracle Linux 6 guests:# yum install yum-utils -y # yum-config-manager --enable ol6_latest # yum install qemu-guest-agent
For Oracle Linux 5 guests:# yum install yum-utils -y # yum install http://yum.oracle.com/repo/OracleLinux/OL7/ovirt42/x86_64/getPackage/ \ ovirt-guest-agent-1.0.13-2.el5.noarch.rpm
-
Start the guest agent service for the Oracle Linux guest.
For Oracle Linux 8 and Oracle Linux 7 guests:
# systemctl start qemu-guest-agent.service
For Oracle Linux 6 guests:# service qemu-ga enable # service qemu-ga start
For Oracle Linux 5 guests:# service ovirt-guest-agent enable # service ovirt-guest-agent start
-
(Optional) Enable an automatic restart of the guest agent service when the virtual machine is rebooted.
For Oracle Linux 8 and Oracle Linux 7 guests:
# systemctl enable qemu-guest-agent.service
For Oracle Linux 6 guests:# chkconfig qemu-ga on
For Oracle Linux 5 guests:# chkconfig ovirt-guest-agent on
Installing the Microsoft Windows Guest OS
To install the Microsoft Windows guest OS:
-
From the Virtual Machines pane, select a virtual machine.
-
Using the down arrow next to Run, select Run Once.
- Expand the Boot Options menu, check Attach CD, and select the ISO image.
- Click OK to boot the virtual machine.
-
Click Console to open a console to the virtual machine.
If you have not installed the Remote Viewer application, refer to Installing Remote Viewer on Client Machine.
-
Install the Microsoft Windows guest OS.
Refer to the applicable Microsoft Windows documentation for instructions on how to install the operating system.
- When the installation completes, reboot the virtual machine.
-
Proceed to Installing the VirtIO Drivers and then to Installing the QEMU Guest Agent.
Installing the VirtIO Drivers
Before attempting to install the Oracle VirtIO Drivers for Microsoft Windows on a new Microsoft Windows virtual machine, ensure that you have downloaded the drivers onto the Manager host and uploaded the ISO image to an Oracle Linux Virtualization Manager storage domain. For more information, see the prerequisites.
To install the Oracle VirtIO Drivers for Microsoft Windows:
-
After you finish installing the Microsoft Windows guest OS, return to the Virtual Machines pane, highlight the row for this virtual machine, and click Edit.
The Edit Virtual Machines dialog box opens.
-
Click the Boot Options tab on the sidebar of the dialog box to specify the boot sequence for the virtual device.
-
From the First Device drop-down list, change CD-ROM to Hard Disk.
-
From the Second Device drop-down list, select CD-ROM.
-
Select the Attach CD checkbox and choose virtio from the drop-down list.
-
-
Click OK to save the changes to the virtual machine configuration.
-
Click OK when the Pending Virtual Machine changes dialog box appears.
-
From the Virtual Machines pane, reboot the virtual machine.
-
Click Console to open a console to the virtual machine and navigate to the CDROM.
-
Double-click the virtio folder and then click Setup to start the Oracle VirtIO Drivers for Microsoft Windows installer.
The installer window is displayed.
-
Click Install to start the Oracle VirtIO Drivers for Microsoft Windows installer.
The installer copies the Oracle VirtIO Drivers for Microsoft Windows installer files and then installs the drivers on the Microsoft Microsoft Windows guest operating system.
-
Click Yes, I want to restart my computer now and click Finish.
The virtual machine is restarted.
-
Stop the virtual machine.
-
Go to Compute and then click Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Select the virtual machine where you installed the Microsoft Windows guest OS and click Edit.
-
Edit the virtual disk. From the Interface drop-down list, change SATA to VirtIO-SCSI .
-
Click the Boot Options tab on the sidebar.
-
Do not make any changes to the First Device drop-down list. The Hard Disk option is selected from a previous step.
-
From the Second Device drop-down list, select None.
-
Deselect the Attach CD checkbox.
-
-
Click OK to save the changes to the virtual machine configuration.
- Restart the virtual machine.
-
Proceed to Installing the QEMU Guest Agent.
Installing the QEMU Guest Agent
Before attempting to install the QEMU guest agent on a new Microsoft Windows virtual machine, ensure that you have downloaded the drivers onto the Manager host. For more information, see the prerequisites.
- On the Manager host, install the QEMU guest
agent.
# dnf install qemu-ga-win
- Verify the installation.
# ls -lat /usr/i686-w64-mingw32/sys-root/mingw/bin/ total 9280 drwxr-xr-x. 2 root root 30 Nov 3 13:56 . -rw-r--r--. 1 root root 9499648 Nov 2 09:45 qemu-ga-i386.msi drwxr-xr-x. 3 root root 17 Sep 23 19:02 .. # ls -lat /usr/x86_64-w64-mingw32/sys-root/mingw/bin/ total 9472 drwxr-xr-x. 2 root root 32 Nov 3 13:56 . -rw-r--r--. 1 root root 9697280 Nov 2 09:45 qemu-ga-x86_64.msi
Important:
- If you have access to the virtual machine, you can copy the appropriate MSI (32-bit or 64-bit) to the virtual machine and then run the installer to install the QEMU guest agent.
- If you do not have access to the virtual machine, use the following steps to build and upload an ISO and then install the QEMU guest agent.
Build the ISO and install the QEMU guest agent on the virtual machine.
- Build the QEMU guest agent ISO.
# dnf install genisoimage -y # pwd /root # mkdir build-iso # cp /usr/i686-w64-mingw32/sys-root/mingw/bin/qemu-ga-i386.msi build-iso/ # cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/qemu-ga-x86_64.msi build-iso/ # mkisofs -R -J -o qemu-ga-windows.iso build-iso/* I: -input-charset not specified, using utf-8 (detected in locale settings) Using QEMU_000.MSI;1 for /qemu-ga-x86_64.msi (qemu-ga-i386.msi) 52.36% done, estimate finish Thu Nov 3 14:20:49 2022 Total translation table size: 0 Total rockridge attributes bytes: 347 Total directory bytes: 0 Path table size(bytes): 10 Max brk space used 0 9549 extents written (18 MB) # ll qemu-ga-windows.iso -rw-r--r--. 1 root root 19556352 Nov 3 14:20 qemu-ga-windows.iso
- Upload the QEMU guest agent ISO image to an Oracle Linux Virtualization Manager storage domain. Refer to Uploading an ISO Image to the Data Domain for more information.
-
From the Virtual Machines pane, select a virtual machine.
-
Highlight the row for this virtual machine, and click Edit.
The Edit Virtual Machines dialog box opens. -
Click the Boot Options tab on the sidebar of the dialog box to specify the boot sequence for the virtual device.
-
From the First Device drop-down list, change CD-ROM to Hard Disk.
-
From the Second Device drop-down list, select CD-ROM.
-
Select the Attach CD checkbox and choose the qemu executable from the drop-down list.
-
-
Click OK to save the changes to the virtual machine configuration.
-
Click OK when the Pending Virtual Machine changes dialog box appears.
-
From the Virtual Machines pane, reboot the virtual machine.
-
Click Console to open a console to the virtual machine and navigate to the CDROM.
-
Double-click the the qemu executable to launch the installation program.
-
When installation completes, click Yes, I want to restart my computer now and click Finish.
The virtual machine is restarted.
-
Stop the virtual machine.
-
Go to Compute and then click Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Select the virtual machine where you installed the Microsoft Windows guest OS and click Edit.
-
Click the Boot Options tab on the sidebar.
-
Do not make any changes to the First Device drop-down list. The Hard Disk option is selected from a previous step.
-
From the Second Device drop-down list, select None.
-
Deselect the Attach CD checkbox.
-
-
Click OK to save the changes to the virtual machine configuration.
-
From the Virtual Machines pane, reboot the virtual machine.
-
Run the Microsoft Windows virtual machine.
For more information, see the Oracle® Linux: KVM User's Guide
Live Editing a Virtual Machine
You can optionally change many settings for a virtual machine while it is running.
-
From the Administration Portal, click Compute and then select Virtual Machines.
-
Under the Name column, select the virtual machine you want to make changes to and then click Edit.
-
On the bottom left of the Edit Virtual Machine window, click Show Advanced Options.
-
Change any of the following properties while the virtual machine is running without restarting the virtual machine.
Select the General tab, to modify:
-
Optimized for
You can select from three options:
-
Desktop - the virtual machine has a sound card, uses an image (thin allocation), and is stateless.
-
Server - the virtual machine does not have a sound card, uses a cloned disk image, and is not stateless. In contrast, virtual machines optimized to act as desktop machines.
-
High Performance - the virtual machine is pre-configured with a set of suggested and recommended configuration settings for reaching the best efficiency.
-
Name
A virtual machine's name must be unique within the data center. It must not contain any spaces and must contain at least one character from A-Z or 0-9. The maximum length is 255 characters.
The name can be re-used in different data centers within Oracle Linux Virtualization Manager.
-
Description and Comment
-
Delete Protection
If you want to make it impossible to delete a virtual machine, check this box. If you later decide you want to delete the virtual machine, remove the check.
-
Network Interfaces
Add or remove network interfaces or change the network of an existing NIC.
-
Select the System tab, to modify:
-
Memory Size
Use to hot plug virtual memory. For more information, see Hot Plugging Virtual Memory.
-
Virtual Sockets (Under Advance Parameters)
Use to hot plug CPUs to the virtual machine. Do not assign more sockets to a virtual machine than are present on its KVM host. For more information, see Hot Plugging vCPUs.
Select the Console tab, to modify:
-
Disable strict user checking
By default, strict checking is enabled allowing only one user to connect to the console of a virtual machine until it has been rebooted. The exception is that a SuperUser can connect at any time and replace a existing connection. When a SuperUser has connected, no normal user can connect again until the virtual machine is rebooted.
Important:
Check this box with caution because you can expose the previous user's session to the new user.
Select the High Availability tab, to modify:
-
Highly Available
Check this box if you want the virtual machine to automatically live migrate to another host if its host crashes or becomes non-operational. Only virtual machines with high availability are restarted on another host. If the virtual machine's host is manually shut down, the virtual machine does not automatically live migrate to another host. For more information, see Configuring a Highly Available Virtual Machine.
Note:
You are not able to check this box if on the Host tab you have selected either Allow manual migration only or Do not allow migration for the Migration mode. For a virtual machine to be highly-available it must be possible for the engine to migrate the virtual machine to another host when needed.
-
Priority for Run/Migration Queue
Select the priority level (Low, Medium or High) for the virtual machine to live migrate or restart on another host.
Select the Icon tab, to upload a new icon.
-
-
Click OK when you are finished with all tabs to save your changes.
Changes to any other settings are applied when you shut down and restart your virtual machine. Until then, an orange icon displays to indicate pending changes.
Migrating Virtual Machines between Hosts
Virtual machines that share the same storage domain can live migrate between hosts that belong to the same cluster. Live migration allows you to move a running virtual machine between physical hosts with no interruption to service. The virtual machine stays powered on and user applications continue running while the virtual machine is relocated to a new physical host. In the background, the virtual machine's RAM is copied from the source host to the destination host. Storage and network connectivity are not changed.
You use live migration to seamlessly move virtual machines to support a number of common maintenance tasks. Ensure that your environment is correctly configured to support live migration well in advance of using it.
Configuring Your Environment for Live Migration
To enable successful live migrations, you should ensure you correctly configure it. At a minimum, to successfully migrate running virtual machines:
-
Source and destination hosts should be in the same cluster
-
Source and destination hosts must have a status of
Up
. -
Source and destination hosts must have access to the same virtual networks and VLANs
-
Source and destination hosts must have access to the data storage domain where the virtual machines reside
-
There must be enough CPU capacity on the destination host to support the virtual machine's requirements.
-
There must be enough RAM on the destination host that is not in use to support the virtual machine's requirements
Note:
Live migrations are performed using the management network. The number of concurrent migrations supported is limited by default. Even with these limits, concurrent migrations can potentially saturate the management network. To minimize the risk of network saturation, we recommended that you create separate logical networks for storage, display, and virtual machine data.
To configure virtual machines so they reduce network outage during migration:
-
Ensure that the destination host has an available virtual function (VF)
-
Set the Passthrough and Migrateable options in the passthrough vNIC’s profile
-
Enable hotplugging for the virtual machine's network interface
-
Ensure that the virtual machine has a backup VirtIO vNIC to maintain the virtual machine's network connection during migration
-
Set the VirtIO vNIC’s No Network Filter option before configuring the bond
-
Add both vNICs as subordinate under an active-backup bond on the virtual machine, with the passthrough vNIC as the primary interface
Automatic Virtual Machine Migration
The Engine automatically initiates live migration of virtual machines in two situations:
-
When a host is moved into maintenance mode live migration is initiated for all virtual machines running on the host. The destination host for each virtual machine is assessed as the virtual machine is migrated, in order to spread the load across the cluster.
-
To maintain load balancing or power saving levels in line with scheduling policy live migrations are initiated.
You can disable automatic, or even manual, live migration of specific virtual machines if required.
Setting Virtual Machine Migration Mode
Using the Migration mode setting for a virtual machine, you can allow automatic and manual migration, disable automatic migration, or disable automatic and manual migration. If a virtual machine is configured to run only on a specific host, you cannot migrate in manually.
To set a virtual machine's migration mode:
From the Migration mode drop-down list, select Allow manual and automatic migration, Allow manual migration only or Do not allow migration.
To set the migration mode of a virtual machine:
-
Click Compute and select Virtual Machines.
-
Select a virtual machine and click Edit.
-
Click the Host tab.
-
Use the Start Running On radio buttons to specify whether the virtual machine should run on any host in the cluster, a specific host, or a group of hosts.
If the virtual machine has host devices attached to it, and you choose a different host, the host devices from the previous host are removed from the virtual machine.
Attention:
Assigning a virtual machine to one specific host and disabling migration is mutually exclusive in Oracle Linux Virtualization Manager high availability (HA). Virtual machines that are assigned to one specific host can only be made highly available using third-party HA products. This restriction does not apply to virtual machines that are assigned to a group of hosts.
-
From the Migration mode drop-down list, select Allow manual and automatic migration, Allow manual migration only or Do not allow migration.
-
(Optional) Check Use custom migration downtime and specify a value in milliseconds.
-
Click OK.
Manually Migrate a Virtual Machine
To manually migrate a virtual machine:
-
Click Compute and the select Virtual Machines.
-
Select a running virtual machine and click Migrate.
-
Choose either Select Host Automatically or Select Destination Host and select the destination host from the drop-down list.
When you choose Select Host Automatically, the system determines the destination host according to the load balancing and power management rules set up in the scheduling policy.
-
Click OK.
During migration, progress is shown in the
Status
field. When the virtual machine has
been migrated, the Host
field updates to
show the virtual machine's new host.
Working with Templates
For this example scenario, you seal the Oracle Linux virtual machine created in Creating a New Virtual Machine and then you create an Oracle Linux template based on that virtual machine. You then use that template as the basis for a Cloud-Init enabled template to automate the initial setup of a virtual machine.
A template is a copy of a virtual machine that you can use to simplify the subsequent, repeated creation of similar virtual machines. Templates capture the configuration of software, the configuration of hardware, and the software installed on the virtual machine on which the template is based, which is known as the source virtual machine.
Virtual machines that are created based on a template use the same NIC type and driver as the original virtual machine but are assigned separate, unique MAC addresses.
Important:
Oracle provides pre-installed and pre-configured templates that allow you to deploy a fully configured software stack. Use of Oracle Linux templates eliminates the installation and configuration costs and reduces the ongoing maintenance costs. For more information, see Importing an Oracle Linux Template.
Sealing an Oracle Linux Virtual Machine for Use as a Template
Sealing is the process of removing all system-specific details from a virtual machine before creating a template based on that virtual machine. Sealing is necessary to prevent the same details from appearing on multiple virtual machines that are created based on the same template. It is also necessary to ensure the functionality of other features, such as predictable vNIC order.
To seal an Oracle Linux virtual machine for use as a template:
-
Log in to the Oracle Linux virtual machine as the
root
user. -
Flag the system for reconfiguration.
# touch /.unconfigured
-
Remove the SSH host keys.
# rm -rf /etc/ssh/ssh_host_*
-
Do one of the following:
- For Oracle Linux 6 (or earlier), set the host name value of the
HOSTNAME=localhost.localdomain
in the/etc/sysconfig/network
file. - For Oracle Linux 7 remove the
/etc/hostname
file.
- For Oracle Linux 6 (or earlier), set the host name value of the
-
Remove /
etc/udev/rules.d/70-*
.# rm -rf /etc/udev/rules.d/70-*
-
Remove the
HWADDR
andUUID
lines in the/etc/sysconfig/network-scripts/ifcfg-eth*
file. -
(Optional) Delete all the logs from
/var/log
and build logs from/root
. -
Cleanup the command history.
# history -c
-
Shutdown the virtual machine.
# poweroff
The Oracle Linux virtual machine is now sealed and ready to be made into a template.
Creating an Oracle Linux Template
When you create a template based on a virtual machine, a read-only copy of the virtual machine's disk is created. This read-only disk becomes the base disk image of the new template, and of any virtual machines that are created based on the template.
To create an Oracle Linux template:
-
Go to Compute, and then click Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Click More Actions to expand the drop-down list and select Make Template from the drop-down list.
The following screenshot shows the More Actions drop-down list expanded to display the Make Template option. The Make Template option is highlighted with a red rectangular box for emphasis.
Figure 3-4 Make Template Option
-
For the Name field, enter a name for the new virtual machine template.
-
In the Disc Allocation: section under the Alias column, rename the disk alias to be the same as the template name entered for the Name field.
-
Click the Seal Template (Linux only) checkbox.
The following screenshot shows the New Template dialog box completed for a new template named
ol7-vm-template
. In the dialog box, the disk alias has been renamed tool7-vm-template
and the Seal Template (Linux only) checkbox is selected.Figure 3-5 New Template Dialog Box
-
Click the OK button to create the template.
The virtual machine displays a status of image
Locked
while the template is being created. The time it takes for the template to be created depends on the size of the virtual disk and the capabilities of your storage hardware. When the template creation process completes, the template is added to the list of templates displayed on the Templates pane.You can now create new Oracle Linux virtual machines that are based on this template.
Creating a Cloud-Init Enabled Template
For Oracle Linux 7 (and later) virtual machines, you can use the Cloud-Init tool to automate the initial setup of virtual machines. Common tasks, such as configuring host names, network interfaces, and authorized keys, can be automated by using this tool. When provisioning virtual machines that have been deployed based on a template, the Cloud-Init tool can be used to prevent conflicts on the network.
Before you create Cloud-Init enabled templates, ensure the following prerequisites are met:
-
You must have sealed an Oracle Linux for use as a template. For more information, refer to Sealing an Oracle Linux Virtual Machine for Use as a Template.
-
You must create a template. For more information, refer to Creating an Oracle Linux Template.
-
The
cloud-init
package must first be installed on the virtual machine. Once installed, the Cloud-Init service starts during the boot process and searches for instructions on what to configure. Use the Run Once window to provide these instructions on a one-time only basis.
Installing the Cloud-Init Package
Note:
The following procedure assumes your operating system is Oracle Linux 8 or later.To install Cloud-Init on a virtual machine:
-
Log in to a Oracle Linux virtual machine.
-
List the
cloud-init
package.# dnf list cloud-init
-
Install the
cloud-init
package.# dnf install cloud-init
-
Run the following command to enable the
cloud-init
service.# systemctl enable cloud-init
-
Run the following command to start the cloud-init service.
# systemctl start cloud-init
Using Cloud-Init to Automate the Initial Setup of a Virtual Machine
To use Cloud-Init to automate the initial setup of a virtual machine:
-
Go to Compute and then click Templates.
The Templates pane opens with the list of templates that have been created.
-
Select a template and click the Edit button.
-
Click Show Advanced Options.
-
Click the Initial Run tab and select the Use Cloud-Init/Sysprep check box.
-
Expand the Authentication section.
-
Select the Use already configured password check box to use the existing credentials, or clear that check box and enter a
root
password in the Password and Verify Password text fields to specify a newroot
password. -
Enter any SSH keys to be added to the authorized hosts file on the virtual machine in the SSH Authorized Keys text area.
-
Select the Regenerate SSH Keys check box to regenerate SSH keys for the virtual machine.
-
-
Expand the Networks section.
-
Enter any DNS servers in the DNS Servers text field.
-
Enter any DNS search domains in the DNS Search Domains text field.
-
Select the In-guest Network Interface check box and use the + Add new and - Remove selected buttons to add or remove network interfaces to or from the virtual machine.
Important:
You must specify the correct network interface name and number (for example,
eth0
,eno3
,enp0s
); otherwise, the virtual machine’s interface connection will be up but will not have the Cloud-Init network configuration.
-
-
Expand the Custom Script section and enter any custom scripts in the Custom Script text area.
Importing an Oracle Linux Template
Oracle provides pre-installed and pre-configured templates that allow you to deploy a fully configured software stack. Use of Oracle Linux templates eliminates the installation and configuration costs and reduces the ongoing maintenance costs.
To import an Oracle Linux template:
-
Download a the template OVA file from http://yum.oracle.com/oracle-linux-templates.html and copy to your KVM host.
-
Assign permissions to the file.
# chown 36:36 /tmp/<myfile>.ova
-
Ensure that the
kvm
user has access to the OVA file's path, for example:# -rw-r--r-- 1 vdsm kvm 872344576 Jan 15 17:43 OLKVM_OL7U7_X86_64.ova
-
In the Admistration Portal, click Compute and then select Templates.
-
Click Import.
-
From the Import Template(s) window, select the following options:
-
Data Center: <datacenter>
-
Source: Virtual Appliance (OVA)
-
Host: <kvm_host_containing_ova>
-
File Path: <full_path_to_ova_file>
-
-
Click Load.
-
From the Virtual Machines on Source list, select the virtual appliance's check box.
Note:
You can select more than one virtual appliance to import.
-
Click the right arrow to move the appliance(s) to the Virtual Machines to Import list and then click Next.
-
Click the Clone field for the template you want to import and review its General, Network Interfaces, and Disks configuration.
-
Click OK.
The import process can take several minutes. Once it completes, you can view the template(s) by clicking Compute and then Templates.
You can now create a virtual machine from your imported template.
Creating an Oracle Linux Virtual Machine from a Template
To create an Oracle Linux virtual machine from a template:
-
Go to Compute and then click Virtual Machines.
-
Click New VM.
-
From the Template drop-down list, select the desired template from the drop-down list. For example, select the template created in Creating an Oracle Linux Template.
-
On the Cluster drop-down list, select the data center and host cluster for the new host.
The Default data center is pre-selected in the drop-down list.
For the procedures to create new data centers or a new clusters, refer to Data Centers or Clusters tasks.
-
At a minimum, complete the following key fields.
For example, if the new Oracle Linux virtual machine that is being created is based on the template that was created in Creating an Oracle Linux Template:
-
Name - enter a name for the virtual machine, for example
ol7-vm2
. -
Cluster - select a cluster or leave Default option selected.
-
Template - select a template, for example,
ol7-vm-template
. -
Operating System - select an operating system, for example,
Oracle Linux 7.x x64
. -
nic1 - select a logical network, for example,
vm_pub
.
-
-
Click OK to create the virtual machine from the template.
Once created, the new virtual machine appears in the Virtual Machines pane and shows a status of
Down
. -
Highlight the virtual machine that you created from the template. From the drop-down arrow next to Run, select Run Once to customize the template on-the-fly to create users, set passwords, configure the network.
The red down arrow icon to the left of the virtual machine turns green and the Status column displays
Up
when the virtual machine is up and running on the network.Depending on your template, you might need to configure the Cloud-Init option when you run the virtual machine for the first time:
- From the drop-down arrow next to Run, select Run Once
- Expand Initial Run and check Use Cloud-init,
- The hostname is pre-filled. Fill in other options such as a new user and password, network configuration, timezone.
- Add a cloud-init script.
Working with Virtual Machine Snapshots
A snapshot is a view of a virtual machine’s operating system and applications on any or all available disks at a given point in time. You can take a snapshot of a virtual machine before you make a change to it that may have unintended consequences. If needed, you can use the snapshot to return the virtual machine to its previous state.
Note:
For best practices when using snapshots, see Considerations When Using Snapshots in the Oracle Linux Virtualization Manager: Architecture and Planning Guide.
Creating a Snapshot of a Virtual Machine
Note:
This procedure is for taking a live snapshot. The QEMU guest agent must be installed and theqemu-guest-agent
service must be up and
running.
-
Click Compute and then select Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Under the Name column, select the virtual machine for which to take a snapshot.
The General tab opens with details about the virtual machine.
-
Click the Snapshots tab.
-
Click Create.
-
(Optional) For the Description field, enter a description for the snapshot.
-
(Optional) Select the Disks to include checkboxes. By default, all disks are selected.
Important:
Not selecting a disk results in the creation of a partial snapshot of the virtual machine without a disk. Although a saved partial snapshot does not have a disk, you can still preview a partial snapshot to view the configuration of the virtual machine.
-
(Optional) Select the Save Memory check box to include the virtual machine's memory in the snapshot. By default, this checkbox is selected.
-
Click OK to save the snapshot.
The virtual machine’s operating system and applications on the selected disks are stored in a snapshot that can be previewed or restored.
On the Snapshots pane, the
Lock
icon appears next to the snapshot as it is being created. Once complete, the icon changes to theSnapshot
(camera) icon. You can then display details about the snapshot by selecting the General, Disks, Network Interfaces, and Installed Applications drop-down views.
Restoring a Virtual Machine from a Snapshot
Note:
The virtual machine must be in a Down
state before performing this
task.
To restore a virtual machine from a snapshot:
-
Click Compute and then select Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Under the Name column, select the virtual machine that you want to restore from a snapshot.
The General tab opens with details about the virtual machine.
-
Click the Snapshots tab.
-
On the Snapshots pane, select the snapshot to be used to restore the virtual machine.
-
From the Preview drop-down list, select Custom.
On the Virtual Machines pane, the status of the virtual machine briefly changes to
Image Locked
before returning toDown
.On the Snapshots pane, the
Preview
(eye) icon appears next to the snapshot when the preview of the snapshot is completed. -
Click Run to start the virtual machine.
The virtual machine runs using the disk image of the snapshot. You can preview the snapshot and verify the state of the virtual machine.
-
Click Shutdown to stop the virtual machine.
-
From the Snapshot pane, perform one of the following steps:
-
Click Commit to permanently restore the virtual machine to the condition of the snapshot. Any subsequent snapshots are erased.
-
Alternatively, click Undo to deactivate the snapshot and return the virtual machine to its previous state.
-
Creating a Virtual Machine from a Snapshot
Before performing this task, you must create a snapshot of a virtual machine. For more information, refer to Creating a Snapshot of a Virtual Machine.
-
Click Compute and then select Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Under the Name column, select the virtual machine with the snapshot that you want to use as the basis from which to create another virtual machine.
The General tab opens with details about the virtual machine.
-
Click the Snapshots tab.
-
On the Snapshots pane, select the snapshot from which to create the virtual machine.
-
Click Clone.
The Clone VM from Snapshot dialog box opens.
-
For the Name field, enter a name for the virtual machine.
Note:
The Name field is the only required field on this dialog box.
After a short time, the cloned virtual machine appears on the Virtual Machines pane with a status of
Image Locked
. The virtual machine remains in this state until the Manager completes the creation of the virtual machine. When the virtual machine is ready to use, its status changes fromImage Locked
toDown
on the Virtual Machines pane.
Deleting a Snapshot
You can delete a virtual machine snapshot and permanently remove
it from your virtualization environment. This operation is
supported on a running virtual machine and does not require the
virtual machine to be in a Down
state.
Important:
-
When you delete a snapshot from an image chain, there must be enough free space in the storage domain to temporarily accommodate both the original volume and the newly merged volume; otherwise, the snapshot deletion fails. This is due to the data from the two volumes being merged in the resized volume and the resized volume growing to accommodate the total size of the two merged images. In this scenario, you must export and reimport the volume to remove the snapshot.
-
If the snapshot being deleted is contained in a base image, the volume subsequent to the volume containing the snapshot being deleted is extended to include the base volume.
-
If the snapshot being deleted is contained in a QCOW2 (thin-provisioned), non-base image hosted on internal storage, the successor volume is extended to include the volume containing the snapshot being deleted.
To delete a snapshot:
-
Click Compute and then select Virtual Machines.
The Virtual Machines pane opens with the list of virtual machines that have been created.
-
Under the Name column, select the virtual machine with the snapshot that you want to delete.
The General tab opens with details about the virtual machine.
-
Click the Snapshots tab.
-
On the Snapshots pane, select the snapshot to delete.
-
Select the snapshot to delete.
-
Click Delete.
-
Click OK.
On the Snapshots pane, a
Lock
icon appears next to the snapshot until the snapshot is deleted.