# Create a Ubuntu Virtual Machine Using ISO Image

This guide outlines deploying a Ubuntu linux virtual machine using an ISO image in <code class="expression">space.vars.product\_name</code> environment. The procedure involves uploading an ISO, creating a VM, attaching storage, installing OS, and converting the result into a reusable image.

## Prerequisites

Before beginning the deployment process, ensure your environment meets the following requirements:

1. A fully operational PCD environment with:
   1. A configured Image Library node
   2. A Block storage node for storage management
2. Local access to the desired ISO image on a machine with network connectivity to the Image Library node

## Deployment Process

### Upload ISO Image to Image Library

Upload the ISO image to the image library service using the OpenStack CLI:

{% tabs %}
{% tab title="Bash" %}

```bash
# Create a new image entry
openstack image create \
    --insecure \
    --container-format bare \
    --disk-format iso \
    --public \
    --file ubuntu-20.04.6-live-server-amd64.iso \
    ubuntu-iso
```

{% endtab %}
{% endtabs %}

Verify image status

{% tabs %}
{% tab title="Bash" %}

```bash
openstack image show IMAGE_ID --insecure --fit-width
```

{% endtab %}
{% endtabs %}

### Deploy Virtual Machine

Deploy a VM using either the UI or CLI:

Using CLI:

{% tabs %}
{% tab title="Bash" %}

```bash
openstack server create \
    --image ubuntu-iso \
    --nic net-id=NETWORKUUID \
    --flavor FLAVOR_ID \
    INSTANCE_NAME
```

{% endtab %}
{% endtabs %}

Using UI:

1. Navigate to "Deploy Virtual Machine"
2. Select "Boot VM from image"
3. Choose the uploaded ISO image
4. Configure flavor and network settings
5. Specify VM name
6. Initiate deployment

### Configure Bootable Volume

Create and attach a bootable volume to store the operating system installation:

Creating volume via CLI:

{% tabs %}
{% tab title="Bash" %}

```bash
openstack volume create \
    --size SIZE_IN_GB \
    --bootable \
    VOLUME_NAME
```

{% endtab %}
{% endtabs %}

Attach volume via CLI:

{% tabs %}
{% tab title="Bash" %}

```bash
openstack server add volume \
    INSTANCE_NAME \
    VOLUME_NAME \
    --device /dev/vda
```

{% endtab %}
{% endtabs %}

Using UI:

1. Navigate to Volumes → Create New Volume
2. Select "Empty Volume"
3. Configure volume parameters:
   1. Name
   2. Size
   3. Volume type
   4. Enable bootable flag
4. Attach volume through VM management interface:
   1. Virtual Machines → Select VM
   2. Select 'Manage Volumes' action.
   3. Attach the newly created volume

### Install Ubuntu

You can access the virtual machine console through <code class="expression">space.vars.product\_acronym</code> UI by navigating to Virtual Machines menu option, then identifying the VM in the grid view, then selecting 'console' action for the VM. Use the console to complete the OS installation process according to your requirements.

### Create Image from Volume

After you've successfully installed Ubuntu, remove the temporary virtual machine instance:

{% tabs %}
{% tab title="Bash" %}

```bash
openstack server delete INSTANCE_NAME
```

{% endtab %}
{% endtabs %}

Convert volume to image:

{% tabs %}
{% tab title="Bash" %}

```bash
openstack image create \
    --volume SOURCE_VOLUME \
    IMAGE_NAME
```

{% endtab %}
{% endtabs %}

### Deploy VM from Image

Deploy the final virtual machine using the newly created image through either:

* Virtual Machines menu option in <code class="expression">space.vars.product\_name</code> UI, selecting the image created in step 5
* CLI using the standard OpenStack server create command with the new image
