# Machine Images

Machine images are a fundemental part of Compute services. A machine image
is a single file which contains a virtual disk on which a bootable operating
system is installed. It allows a user to create a VM instance with any OS.

<a id="id1"></a>

## Image Requirements

Machine images can be created from the following source formats:

* VMware OVA image.
* KVM compatible image in RAW or QCOW2 formats.

Supported images must meet the following requirements:

* The image must be a single bootable system disk.
* The image must be configured to receive a network address via DHCP.
* User access to the VM instance is required and depends on the image type:
  * **Windows Image** - use VNC or enable Remote Access Service.
  * **Linux Image** - use SSH server service.

<a id="newimage-ref"></a>

## Image Creation

See the video on the basics of zCompute Machine Images and ISOs:

<iframe class="embed-responsive-item"
        id="youtubeplayer"
        type="text/html"
        width="640"
        height="390"
        style="border: none"
        src="//www.youtube.com/embed/i892xmKMJoo"
        allowfullscreen="allowfullscreen">
</iframe>

Images can be created from different UI views.

### Create Images from Machine Image View

**To create image from Machine Image view:**

1. Navigate to the **Main menu > Machine Images** view and select **Images**.
   <!-- comment
   placeholder for updated screenshot when Volume Type col has values -->

   ![image-list](media/image-list.png)
2. In the displayed image list view, click **Create** in the top toolbar.

   ![create-image-details](media/create-image-details.png)
3. In the **Create Image** window, configure the following:
   * **Name** - name that will identify the image.
   * **Description** - description that will help identify the image purpose.
   * **Project** (cloud admin view only) - select the project from the dropdown.
   * **Firmware Type** - select UEFI or BIOS.
   * **Operating System** - select the required operating system.
   * **Scope** - determines which users can access this image:
     * **Project** - only users with access to the project.
     * **Account** - all account users.
   * **Tags** - attach one or more tags to the image.
4. Click **Next**.

   ![create-image-setup](media/create-image-setup.png)
5. In the **Setup** tab, configure:
   * **Create Image From:** - the source to use for creating the new image.
     When you select one of the source options, the next field is updated
     as follows:
     * **File** - configure:
       * **Volume Type** - select the volume type from the dropdown list.
       * **File** - drag the image file into the **File** box, or browse
         to the file and select it.
     * **URL** - configure:
       * **Volume Type** - select the volume type from the dropdown list.
       * **Use Legacy IDE** - select legacy IDE or native IDE.
       * **Override Size** - select whether to keep the image the same
         size or to override it. To override the size, enter the new size.
       * **Disk Type** - select whether to attach the image file as a Disk
         or CDROM.
       * Click **Add** to configure an additional mapping.
     * **Snapshot/Volume** - configure:
       * **Snapshot/Volume** - source to be used to create image.
       * **Volume Type** - select the volume type from the dropdown list.
       * **Use Legacy IDE** - select legacy IDE or the native IDE.
       * **Override Size** - select whether to keep the image the same
         size or to override it. To override the size, enter the new size.
       * **Disk Type** - select whether to attach the image file as a Disk
         or CDROM.
       * Click **Add** to configure an additional mapping.
6. Click the **Finish** button. The image begins to be created. When the
   uploading progress is completed, the **Action Succeeded** message is
   displayed.

   ![image5](media/image5.png)

### Create Images from Storage View

New image creation from an existing volume can be done from the storage
view as well. Create an image from a volume, either directly from the
volume or by using a snapshot of the volume. If the volume is currently not
attached to a running VM instance, create an image as described below. If the
volume is attached to a running VM instance which can not be stopped, first
detach the volume and create a snapshot, and then create an image from the
snapshot.

**To create an image from a volume in storage view**

1. Navigate to the **Storage > Block Storage** view.
2. In the displayed list, select the volume to be used to create the image.
3. In the top toolbar, select **Create Image**.

   ![create-image-block-storage](media/create-image-block-storage.png)
4. In the displayed **Create Image From Volume** window, configure the following:
   * **Name** - name that will identify the image.
   * **Description** - description that will help identify the image purpose.
   * **Tags** - attach one or more tags to the image.
   * **Operating System** - select the required operating system.
5. Click **OK**. The new image is displayed in the **Machine Images > Images**
   list.

### Create Images from Snapshot View

The system permits creation of images from a volume snapshot. Using a volume
snapshot as the image source allows the user to create the image without
stopping the VM instance or detaching the volume.

**To create an image from a snapshot:**

1. Navigate to the **Storage > Snapshots** view.
2. In the displayed list, select the snapshot to be used for creating the image
   and click **Create Image** from the top toolbar.

   ![image9](media/image9.png)
3. In the displayed **Create Image** window is displayed, enter the **Name**
   of the new image.

   ![image11](media/image11.png)
4. Click **OK**. The new image is displayed in the **Machine Images > Images**
   list.

## Creating ISO Images

ISO images can only be created from the **Machine Images** UI view.

1. Navigate to the **Main menu > Machine Images** view and select **Images**.
2. In the dispalyed image list view, click **Create ISO** from the top toolbar.
3. In the displayed **Create ISO Image** window, configure the following:

   ![create-iso-image-details](media/create-iso-image-details.png)
   * **Name** - name that will identify the image.

   * **Description** - description that will help identify the image purpose.
   * **Firmware Type** - select UEFI or BIOS.
   * **Operating System** - select the required operating system.
   * **Volume Type** - select the volume type from the dropdown list.
   * **Scope** - determines which users can access this image:
     * **Project** - only users with access to the project.
     * **Account** - all account users.
   * **Tags** - attach one or more tags to the image.
4. Click **Next**. The **Setup > OS Installation Disk** window is displayed.

   ![image17](media/image17.png)
5. Depending on the selected source option, configure the next field as follows:
   * **File** - drag the image file into the **File** box, or browse to the
     file and select it.
   * **Snapshot/Volume** - configure the source snapshot/volume to be used
     to create image.
   * **URL** - enter the URL of the image file and check **Skip SSL verification**
     if needed.
6. For ISO image creation, select **Add Drivers** to include drivers for use
   during and after the operating system installation. The additional drivers
   disk can be created from an existing file or snapshot/volume.
7. Click **Finish**. The ISO Image is displayed in the Images list.

## Windows Server VM Instance Creation

The following section describes how to create a new Windows Server 2019 VM
Instance from an ISO in the zCompute Compute Cloud.

The [latest version](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso)
of virtio drivers has an installer to simplify the installation.

**To create a Windows Server Instance:**

1. Create the Image.
   1. Navigate to **Machine Images > Images**.
   2. From top toolbar, click **Create ISO**.

      ![win-create-iso](media/win-create-iso.png)
   3. In the **Create ISO Image** dialog **Details** tab, enter the following:

      ![win-create-iso-image-details](media/win-create-iso-image-details.png)
      * **Name**
      * **Firmware Type** - select **BIOS**.
      * **Operating System** - select the Windows OS version.
      * **Volume Type** - select the volume type from the dropdown list.
      * **Scope** (cloud admin view only) - select **Account**.
   4. Click **Next**.
   5. In the **Setup** tab, click **Add Drivers**.

      ![win-create-iso-image-setup-os](media/win-create-iso-image-setup-os.png)
   6. Select **URL** (or **File** if images are availably locally), and enter
      the following URLs:

      ![win-create-iso-image-setup-drivers](media/win-create-iso-image-setup-drivers.png)
      * **OS Installation Disk** - Windows ISO.
      * **Additional Drivers Disk** - <[https://zadarastorage-software.s3.us-east-1.amazonaws.com/Windows-ISOs/virtio-win-1.9.15.iso](https://zadarastorage-software.s3.us-east-1.amazonaws.com/Windows-ISOs/virtio-win-1.9.15.iso)>
   7. Click **Finish**.
2. After the upload has completed, navigate to **Compute > Instances**.
   1. From the top toolbar, click **Create**.

      ![win-vm-instance-list](media/win-vm-instance-list.png)
   2. In the **Create VM** dialog **Setup** tab, enter the following:

      ![win-create-vm-compute](media/win-create-vm-compute.png)
      * **Name** - a name that will identify the VM instance.
      * **Project** - the VM instance must be created within a project.
      * **Create From** - select **ISO**.
      * **Installation ISO** - select the ISO image.
      * **Instance Type** - select the instance type with the desired instance size.
      * **Operating System** - select the image’s operating system.
   3. Click **Next** through the **Storage** and **Network** tabs,
      and **Finish** on the **Config** tab.
3. After the instance has been spawned and has the status **Active**,
   navigate to **Compute > Instances**.
4. Select the image and click **Connect** from top toolbar.

   ![win-vm-connect](media/win-vm-connect.png)
5. Run **Windows Setup** to continue with the Windows Server installation.
   1. When prompted for **Type of Installation**, select **Custom**.

      ![image-win17](media/image2020-7-9_12-24-44.png)
   2. When prompted with **Where do you want to install Windows**,
      select **Load Driver**.

      ![image-win18](media/image2020-7-9_12-26-21.png)
   3. When prompted to **Load Driver** click **OK**.

      ![image-win19](media/image2020-7-9_12-28-1.png)
   4. Select the *Red Hat VirtIO SCSI controller* (E:\\amd64\\w10\\viostor.inf)
      option and select **Next**.

      ![image-win20](media/image2020-7-9_12-29-16.png)
   5. Continue as prompted by install wizard for the rest of the installation.
6. After Windows has been installed, log into Windows as Administrator.
   1. Right-click on the **Start Menu** and select **Device Manager**.

      ![image-win21](media/image2020-7-9_12-44-9.png)
   2. Right-click on **Ethernet Controller** and select **Update driver**.

      ![image-win22](media/image2020-7-9_12-46-33.png)
   3. Select **Browse my computer for driver software**.

      ![image-win23](media/image2020-7-9_12-48-14.png)
   4. Select **Browse** and select the **CD Drive (virtio-win-x.x.x)**.

      ![image-win24](media/image2020-7-9_12-51-35.png)
   5. CLick **OK**.
   6. Click **Next**.
   7. When prompted by **Windows Security**, select **Install**.

      ![image-win25](media/image2020-7-9_12-54-19.png)
   8. Repeat this process for the **Display Adapter** and also for
      **Other Device > PCI Device**.

      ![image-win26](media/image2020-7-9_12-56-26.png)
   9. To complete installation, open Windows Explorer and install **QEmu agent**.

      ![image-win27](media/image2020-7-9_12-59-0.png)

### Correcting Windows VM RAM consumption display in zCompute

It is common to see that zCompute UI **Compute > Instances** reports
Windows VMs consuming 100% of the RAM allocated to them, although
the OS actually uses much less RAM.

For example, an incorrect reflection of a VM’s RAM consumption:

* In the **Compute > Instances** list:

  ![compute-instances-memory-wrong](media/compute-instances-memory-wrong.png)
* In the **Compute > Instances >** <VM> detail screen:

  ![compute-instances-vm-memory-wrong](media/compute-instances-vm-memory-wrong.png)
* The actual RAM consumption according to the VM’s Windows
  **Task Manager** screen:

  ![win-taskmanager-memory-usage](media/win-taskmanager-memory-usage.png)

In most cases, the reason for this discrepancy is that the guest VM OS
doesn’t have the Windows VirtIO Balloon driver and service properly
installed, or that they’re outdated.

To rectify the display, you must download and install the Win VirtIO Guest
Tools package, which installs the Balloon driver and service together with
any other missing VirtIO drivers on the VM:

1. Sign in to the Windows VM.
2. Download the VirtIO Guest Tools MSI installer from the Win-VirtIO
   archives website:

   [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win-gt-x64.msi](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win-gt-x64.msi)
3. Right click the downloaded installer and click Install.
4. Accept the terms.
5. In the **Custom Setup** screen select only the following components to
   install:
   * Balloon
   * Network
   * Viostor

   Disable the installation of all other components.
6. Allow the VM to reboot when prompted by the Installer.
7. In the zCompute UI, stop the VM:
   1. Go to **Compute > Instances >** <VM instance>.
   2. Click **Stop** and wait for the VM instance to reach the **Shutoff**
      status.
8. In the zCompute UI, restart the VM:
   1. Go to **Compute > Instances >** <VM instance>.
   2. Click **Start** and wait for the VM instance to reach the **Active**
      status.

The zCompute UI should now report the VM’s correct RAM consumption for
example:

* In the **Compute > Instances** list:

  ![compute-instances-memory-correct](media/compute-instances-memory-correct.png)
* In the **Compute > Instances >** <VM> detail screen:

  ![compute-instances-vm-memory-correct](media/compute-instances-vm-memory-correct.png)

  The zCompute UI’s VM RAM usage values in this example now correctly
  reflect the actual RAM consumption according to the VM’s Windows
  **Task Manager** screen:

  ![win-taskmanager-memory-usage](media/win-taskmanager-memory-usage.png)

## Deleting Images

1. Navigate to the **Main menu > Machine Images** view and select **Images**.
2. From the displayed list, select an image and click **Delete** from the top
   toolbar.

   ![delete-image](media/delete-image.png)
3. In the **Delete Image** window, click **Delete**.

   ![delete-image-confirm](media/delete-image-confirm.png)
4. The Image is deleted, and the following message is displayed:
   **Action Succeeded**.

   ![image15](media/image15.png)

<a id="zcompute-machine-images-marketplace"></a>

## Machine Images Marketplace

The following tested images can be downloaded from the
**Machine Images > Marketplace** view.

### Zadara

* Zadara EKS-D ver. 1.28, ver. 1.29, ver. 1.30
* Zadara zCompute Toolbox Ubuntu ver. 3.0.2

### Managed Services Partners

* Taikun Advanced Managed Kubernetes 22.04

### Operating Systems: Cloud Images

* Alma Linux ver. 9, ver. 10
* CentOS ver. 6, ver. 7, ver. 8
* CirrOS ver. 0.5.1
* Debian ver. 9, ver. 10, ver. 11, ver. 12, ver. 13
* Fedora ver. 42, ver. 43
* Rocky Linux ver. 9, ver. 10
* Ubuntu Bionic ver. 18.04-LTS
* Ubuntu Focal ver. 20.4-LTS
* Ubuntu Jammy ver. 22.04-LTS
* Ubuntu Noble Numbat ver. 24.04-LTS
* Ubuntu Trusty ver. 14.04-LTS
* Ubuntu Xenial ver. 16.04-LTS

### Virtual Appliances: Cloud Images

* Loadbalancer Enterprise ADC ver. 8.9.0
* pfSense-CE ver. 2.7.2

**To download an image from the Zadara Marketplace:**

1. Navigate to the **Machine Images > Marketplace** view.

   ![images-marketplace](media/images-marketplace.png)
2. Select the image to download.

   ![images-toolbox-fedora](media/images-toolbox-fedora.png)
3. In the window which opens, enter the following:
   * **Volume Type** - select the volume type from the dropdown list.
   * **Scope** - determines which users can access this image:
     * **Project** - only users with access to the project.
     * **Account** - all account users.
   * **Firmware Type**: The software that provides low-level control of
     computing device hardware.

     Select one of:
     * **BIOS**: The legacy Basic Input/Output System.
       The first software that runs after a computer starts, BIOS
       performs hardware initialization during the booting process and
       provides runtime services for operating systems, applications and
       IO devices (keyboard, mouse, display).
     * **UEFI**: The newer Unified Extensible Firmware Interface, that
       replaces legacy BIOS.
   * Click **Download**. A new image is registered
     in the system and will appear in the image list.

## AWS Image Import API

The following table describes the supported AWS APIs for Image operations:

| AWS API Name                                                                                                         | Ignored Params   | Optional Params                                                                                                                        | Required Params   | Unsupported Params   |
|----------------------------------------------------------------------------------------------------------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------|-------------------|----------------------|
| [DescribeImportImageTasks](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImportImageTasks.html) |                  | ImportTaskId<br/>MaxResults<br/>NextToken                                                                                              |                   |                      |
| [ImportImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ImportImage.html)                           | []               | Architecture<br/>ClientData<br/>ClientToken<br/>Description<br/>DiskContainer<br/>Hypervisor<br/>LicenseType<br/>Platform<br/>RoleName | []                | []                   |
