# Image Prep (Windows)

This section will go through the steps to prepare a Windows image which can be successfully provisioned to HVM clusters. Additionally, this image can serve as a template from which additional images and HPE Morpheus Enterprise Library items can be built. In this example case, we’ll start from downloading a Windows Server 2019 ISO directly from the Microsoft download center and go all the way through to creating a new Instance Type in HPE Morpheus Enterprise that users can provision on-demand.

With the Windows ISO already downloaded, begin by uploading the ISO as a Virtual Image in HPE Morpheus Enterprise. Virtual Images are added in Library > Virtual Images. Click + ADD and then choose “ISO.” Before adding the file itself, set the following configurations on the Virtual Image:

- **NAME:** A name for the Virtual Image in HPE Morpheus Enterprise, such as “Windows Server 2019 ISO”
- **OPERATING SYSTEM:** “windows server 2019”
- **MINIMUM MEMORY:** Filters out Service Plans at provision time which do not meet the minimum value. For this image type, I’ve set 4 GB

In addition to the above, there are a number of checkbox configurations here (many of them are in the expandable “Advanced” section), some of which are checked by default. They should all be unchecked except for “VIRTIO DRIVERS LOADED?” within the “Advanced” expandable section.

With the configurations set, it’s time to upload the ISO to HPE Morpheus Enterprise. Keep in mind that if you do not specify a bucket in which the file should be uploaded, it will be uploaded to the appliance itself. If you choose to do this, be sure you have enough space to store the images you need. Within the UPLOAD VIRTUAL IMAGE modal is a large dropzone labeled “Drop Files Here.” You can drag and drop the ISO file here or you can click the button labeled “Add File” and browse for it. A progress bar will appear, wait until the file is completely uploaded before you save and dismiss the modal. After the file has completely uploaded, click SAVE CHANGES.

![../../_images/progress.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-984BC461-04D2-4759-9E91-D9ACF2C6EB23-high.png)

Next, we’ll provision a VM from the ISO using the built-in HVM Instance Type. Once running, we will configure the VM to any specific requirements and convert it to a template. Navigate to Provisioning > Instances and click + ADD. On the TYPE tab of the Instance provisioning wizard, we select the Instance Type to provision. In this case, select “HVM” and click NEXT.

![../../_images/provisionMvmInstanceType.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-9DE2A41A-C675-4E94-819C-7DB350F6B8DA-high.png)

On the GROUP tab, select the Group and Cloud containing the target HVM Cluster and provide a name for the new Instance. In my case, I have an automatic naming policy setting my Instance name, but depending on your appliance configuration you may need to enter a custom name. Click NEXT.

![../../_images/groupTab.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-5C1016FB-39ED-4A2E-9D73-3CE2F1C29456-high.png)

On the CONFIGURE tab, first select the IMAGE. Select the Windows server ISO that was uploaded in the previous step. Based on the minimum memory configuration that was set on the Virtual Image, Plans which are too small will be filtered out. Among compatible Plans, select one that meets your requirements. Next, set the RESOURCE POOL, which is the HVM cluster you’re targeting. Configure disks and disk sizes, as well as network details (this will vary based on HVM cluster configuration). Finally, select the HOST, which is the HVM host within the cluster that the new Instance should initially be provisioned onto.

![../../_images/configTabTop.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-8B62B5BD-FAF8-40F3-84C6-E905D7E4E72F-high.png)

As a final step, we need to also expand the “Advanced Options” section and make sure “ATTACH VIRTIO DRIVERS” is checked. This will attach an ISO containing the VirtIO drivers which we’ll use later. Click NEXT.

![../../_images/configTabBottom.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-4F832198-6A42-4B65-96DB-614E7AA109F5-high.png)

The final two tabs of the wizard, AUTOMATION and REVIEW, do not require any configuration changes though you may want to review the Instance settings on the final tab. When done, click COMPLETE.

Click on the newly provisioning Instance from the Instances list page. Since this image is being provisioned for the first time, the image must be uploaded to the HVM host. This can take a little bit of time but any future attempts to provision workloads from this image will skip this step. Wait for the Instance to fully complete and appear in a green “Ready” status.

Once the Instance has fully finished provisioning, launch a console session by clicking ACTIONS and then “Open Console.” This will open a new window with a console session into the VM.

![../../_images/initialConsole.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-83AEDC4E-1DB0-4F7E-ABD9-A3D11F699F3D-high.png)

After selecting the language, click “Next.” On the following screen, click “Install Now.” This will begin the Windows setup process on our new VM. You’ll next select the operating system type you wish to install. For this example, I’m installing 2019 standard with desktop experience. Click “Next.”

![../../_images/chooseOs.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-D2229A74-662F-4D7F-91A4-166C0050AEE5-high.png)

Accept the licensing terms and click “Next.”

![../../_images/eula1.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-270D1487-8799-4388-B67D-3EF2A1EE3631-high.png)

On the next screen, choose a custom install.

![../../_images/clickInstall.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-DFF443AF-638B-4234-860C-811B6717A890-high.png)

The next screen asks where Windows should be installed and may be empty. Click “Load Driver” to locate the mounted disk image containing the VirtIO drivers. The search should return a number of VirtIO SCSI controller packages for various Windows flavors. Select the proper package for the Windows version being installed. Click “Next.”

![../../_images/selectVirtioPackage.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-8941A511-5E0F-4C6B-85F2-BAF23A4AD8CA-high.png)

After a moment, we’re back at the screen asking where Windows should be installed. We should see the disk(s) of size and type selected at the time the VM was provisioned. Select the proper disk and click “Next.” The Windows installation will now begin. Once Windows has fully installed, proceed to the next step.

![../../_images/selectDisk.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-4AE6BBA1-CDFA-4D64-A10E-5797AD61C438-high.png)

Following installation, Windows will restart and prompt for an Administrator user password. Set the password and log in as Administrator. Currently, there are no network interfaces configured. We need to install the VirtIO drivers to get this machine onto the network. We have a disk image mounted with the driver installer so we need to navigate to that drive and launch the installer. Open Windows Explorer and locate the drive in the side bar. In my case, it’s the E: drive. Right-click on `virtio-win-guest-tools` and select “Install.”

![../../_images/windowsExp.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-EE6DD2F5-7B81-4697-8A32-4A04675D0EAC-high.png)

Step through the installer. Simply click “Next” or “Install” through each step, there are no configuration changes needed. Once the installer has completed, click “Finish.” You can confirm we now have a network interface by opening a Command Prompt session and using the `ipconfig` command. One network adapter should be listed.

![../../_images/showInterface.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-55CC0981-E007-492E-BFE7-373ADB87FE9D-high.png)

We can now eject the two virtual disks, drives D: and E: in my case. Then, launch Windows Security so we can disable firewalls. Turn off firewall for domain, private network, and public network.

![../../_images/winDefender.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-DAA8652B-17E0-4AF2-9273-C548F0FA0614-high.png)

Next, back in Command Prompt, run `winrm quickconfig` to configure `winrm`. Within `Services`, ensure that `winrm` (Windows Remote Management) is set to automatic on startup. Right-click on the Start button and select Run. Enter “sysprep” and click OK. In the Windows Explorer window that appears, right-click on `sysprep` and click “Run as Administrator”. Under “Shutdown Options”, choose Quit and click OK. If this is set to shutdown, HPE Morpheus Enterprise will simply restart the VM. Once this is completed, a new file `Sysprep_succeeded.tag` appears in Windows Explorer.

![../../_images/sysprepComplete.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-A11613FB-FC10-42BC-A6A3-3FB44D08260B-high.png)

We’re now done configuring Windows and the console window can be closed. We’ll move on to creating a template from the VM we just configured. Begin by opening an SSH session into the HPE Morpheus Enterprise appliance server. Confirm `jq` is up to date on the appliance box (`apt install jq`). Then, go ahead and stop the running Windows VM. We can do this from the Instance detail page in HPE Morpheus Enterprise. Click ACTIONS and then “Stop Server.” Still on the Instance detail page, click ACTIONS and then “Import as Image.” This will perform a snapshot and create a new Virtual Image (Library > Virtual Images).

![../../_images/importImage.png](https://support.hpe.com/hpesc/public/api/document/sd00007510en_us/GUID-FBFB8AA8-171F-4668-BD6A-CAE4F5870AA8-high.png)

The Virtual Image is not usable until it’s in an active status and the UI indication may display an active status even before it’s fully ready. If it’s “SAVING” or “QUEUED,” it is still being prepared and saved. To determine the current status of the Virtual Image, check with a call to HPE Morpheus Enterprise API like the one below. When the return output lists a status of “Active,” the image is ready to be provisioned from.

```
```
curl -k --request GET --url https://xx.xx.xx.xx/api/virtual-images/<id>  
--header 'accept: application/json' --header 'authorization: Bearer xxx-xxx-xxx-xxx-xxx' |  
jq '.virtualImage.status'
```
```

Once saved, additional configurations are needed on the Virtual Image in HPE Morpheus Enterprise. Edit the new Virtual Image and check the following configurations:

- **MINIMUM MEMORY:** Set as appropriate
- **SYSPREPPED/GENERALIZED IMAGE?:** Checked
- **INSTALL AGENT?:** Checked
- **USERNAME:** Remove if present
- **PASSWORD:** Remove if present
- **VIRTIO DRIVERS LOADED?:** Checked

All other checkbox-type configurations not mentioned in the above list should be unchecked. Click SAVE CHANGES.

At this point all image preparation steps are completed. HPE Morpheus Enterprise library items can now be created from this image by adding new Node Types, Layouts, and Instance Types. The complete steps for building a library item go beyond the scope of this particular guide but more detail on that process is available elsewhere in HPE Morpheus Enterprise UI documentation. Once the library items are created, new Instances may be provisioned complete with HPE Morpheus Enterprise Agent installed.
