# Configuring Linux images for use with HVM Clusters

**Prerequisites**: Read: [System requirements](https://ubuntu.com/server/docs/reference/installation/system-requirements/).

This is an example image prep process for creating a deployable Ubuntu 24.04 image for HVM Clusters.

1. Download the latest Ubuntu 24.04 Server ISO from Canonical.
2. Upload the downloaded Ubuntu ISO as a Virtual Image in the HPE Morpheus VM Essentials Software Manager:

   1. Navigate to Library > Virtual Images
   2. Click Add
   3. Select the downloaded ISO
   4. Configure the "Operating System" (Ubuntu 24.04 64-bit) and leave all other configurations on the default selections. Drag and drop the ISO on the Drop Files Here dropzone near the bottom of the modal.
   5. Wait until the ISO has completely uploaded. There is a progress bar to provide information on the upload process.
   6. Once the ISO has fully uploaded, click Save changes.
3. Provision a new HVM workload to your HVM Cluster:

   1. Navigate to Provisioning > Instances.
   2. Click + ADD.
   3. From the Type tab of the provisioning wizard, select HVM and click Next.
   4. From the Group tab, select the correct Group and Cloud for your HVM Cluster, provide a name for this Instance, and click Next.
   5. On the Configure tab, the exact configurations for the following fields will depend on the environment and available resources. Use the guidelines below to make appropriate selections. At this point, we simply need an accessible VM so we can successfully install the OS, make a few additional configurations (such as installing cloud-init), and save it as a deployable image.

      Plan
      :   A number of default plans ship with Morpheus, using a smaller default plan is fine for this purpose.

      Resource Pool
      :   Select a cluster this VM can run on, when getting started there may only be one.

      Root volume
      :   Smaller size is fine for this purpose and a specific datastore could be manually selected if desired.

      Network
      :   Select the network configured for the instance.

      IMAGE
      :   Select the ISO that was just uploaded.
   6. Click Next and Complete through the next two tabs to stand up the Instance.
4. Install and configure your new VM for image creation:

   1. Click into the newly created Instance to view the Instance detail. Launch the console view so installation and configurations can be completed (ACTIONS > Open Console)
   2. Complete the Ubuntu installation process. In most environments, the default installation configurations will work fine for our purposes here, just ensure the VM will be able to get out to the Internet. During installation, a user profile will be created which will be used to perform additional configurations in the steps ahead.
   3. When installation is complete, reboot the VM. You will be warned that the ISO is still mounted to the virtual machine. Eject the ISO using the UI tools in the Manager (ACTIONS > Eject Disks). Once ejected, continue with the reboot.
   4. Following reboot, log in as the user configured during installation and complete these prep steps:

      1. Run updates: `sudo apt update && sudo apt upgrade -y`
      2. Install cloud-init: `sudo apt install -y cloud-init`
      3. Verify cloud-init is installed: `cloud-init --version`
      4. Enable cloud-init services: `sudo systemctl enable cloud-init cloud-init-local cloud-config cloud-final`
      5. Check status of the service: `sudo systemctl status cloud-init`
      6. Configure cloud-init data sources by editing the following config file: `sudo vi /etc/cloud/cloud.cfg.d/90_dpkg.cfg` with the following configuration: `datasource_list: [ NoCloud, None ]`. Then, save and close the config file
      7. Disable things that break templating: `sudo truncate -s 0 /etc/machine-id` and `sudo rm -f /var/lib/dbus/machine-id`
      8. Clear SSH keys: `sudo rm -f /etc/ssh/ssh_host_*`
      9. Remove persistent network config: `sudo rm -f /etc/netplan/*.yaml`
      10. Clean cloud-init state: `sudo cloud-init clean --logs`
5. Close the console window and shut down the VM using the Manager UI tools from the Instance detail page (ACTIONS > Stop Server.)
6. Still on the Instance detail page, create an image from your stopped Instance (ACTIONS > Import as Image.)
7. Back on the Virtual Images list page, you should see a new Virtual Image object being created
8. Once the image is completely created (status shows as Active), you are ready to provision. Repeat the steps above to add a new Instance but substitute the new deployable image rather than the ISO that was used originally. Now, the disk, network, and default user configurations made during Instance provisioning will apply successfully to new Instances. You can continue to build on this by installing specific software stacks and saving new images for specific service types. Additionally, setup scripts can be written and applied at provision time to add additional orchestration at deployment time.
