---
title: "Prepare an ISO image for use with the cloud platform"
sidebar_label: "Prepare an image for the cloud platform"
sidebar_position: 5
description: "How to prepare an uploaded ISO image for compatibility with the Selectel cloud platform"
---

import Formbricks from '@theme/MDXComponents/Formbricks'

# Prepare an ISO image for use with the cloud platform

If you [have uploaded to the image storage](/cloud-servers/images/create-image.mdx) an ISO image with an operating system distribution, we recommend making it fully compatible with the Selectel cloud platform. From a compatible image, you can create cloud servers that will have the same functionality as servers from [ready-made images](/cloud-servers/images/about-images.mdx#default-images).

## Prepare a Windows image \{#create-windows-image}

1. [Prepare the ISO image locally](#create-windows-image-locally).
2. [Upload the ISO image to the image storage](#upload-windows-image).
3. [Modify the Windows image properties](#modify-windows-image-properties).

### 1. Prepare the ISO image locally \{#create-windows-image-locally}

1. On your local computer, extract the ISO image archive to a separate directory using an archiver, for example `7-zip`, `WinRAR`, `tar`.

2. Download the VirtiO drivers as an ISO image from the [Fedora People](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.266-1/) repository.

3. Create a Drivers directory.

4. Extract the ISO image with VirtiO drivers to the Drivers directory using an archiver, for example `7-zip`, `WinRAR`, `UltraISO`.

5. Transfer the Drivers directory containing the VirtiO drivers to the directory of the Windows ISO image you unpacked in step 1.

6. Install the [DISM++](https://www.chuyu.me/en-US/) utility for image management.

7. Open DISM++.

8. Build the installation image; to do this, go to the **Toolkit** section and select **ISO Maker**.

### 2. Upload the ISO image to the image storage \{#upload-windows-image}

Use the [Upload and create an image from a file](/cloud-servers/images/create-image.mdx#upload-image-from-file) subsection of the Upload and create an image guide.

Specify:

* file — the image that you [prepared in step 1](#create-windows-image);
* OS — Windows;
* image format — `iso`;
* container format — `bare`.

### 3. Modify image properties \{#modify-windows-image-properties}

1. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).

2. Display the IDs of available images:

   ```bash
   openstack image list
   ```

   The response will contain a list of images. Copy the ID of the image you [uploaded in step 2](#upload-windows-image).

3. Optional: view image properties:

   ```bash
   openstack image show
   ```

4. Add the necessary properties:

   ```bash
   openstack image set \
       --property hw_disk_bus=scsi \
       --property hw_firmware_type=uefi \
       --property hw_qemu_guest_agent=yes \
       --property hw_scsi_model=virtio-scsi \
       --property os_type=windows \
       --property x_sel_image_agent_type=cloudbase-init \
       --property x_sel_image_os_arch=amd64 \
       --property x_sel_image_os_dist=windows \
       --property x_sel_image_os_type=windows \
       --property x_sel_image_type=master \
       --property x_sel_kpti_patch=true \
       <image_id>
   ```

   Specify `<image_id>` — the ID of the image you copied in step 2.

## Prepare a Linux image \{#create-linux-image}

:::info

This is a guide for the Oracle Linux image. For other distributions, utilities, repositories, and file locations may differ.

:::

1. [Upload the ISO image to the image storage](#upload-linux-image).
2. [Create a cloud server from the uploaded image](#create-cloud-server).
3. [Configure the cloud server](#configure-server).
4. [Create an image from the cloud server boot disk](#create-linux-image-from-volume).

### 1. Upload the ISO image to the image storage \{#upload-linux-image}

Use the [Upload and create an image](/cloud-servers/images/create-image.mdx) guide.

### 2. Create a cloud server from the uploaded image \{#create-cloud-server}

Use the [Create a cloud server](/cloud-servers/create/create-server.mdx) guide.

Select the uploaded image as the source and a network volume as the boot disk.

### 3. Configure the cloud server \{#configure-server}

1. [Connect to the cloud server](/cloud-servers/manage/connect-to-server.mdx).

2. Add the Selectel OpenStack repositories to the `selectel-openstack.repo` file:

   ```bash
   cat <<EOF > /etc/dnf.repos.d/selectel-openstack.repo
   [selectel-openstack]
   name=selectel-openstack
   baseurl=http://mirror.selectel.org/rpm/centos/7/x86_64
   gpgcheck=1
   gpgkey=http://mirror.selectel.org/selectel-openstack.key
   EOF
   ```

3. Update the package manager repository list:

   ```bash
   dnf update
   ```

4. Install the packages:

   ```bash
   dnf install crontab-randomizer \
   fstrim-blocks qemu-guest-agent \
   set-root-pw \
   cloud-init \
   cloud-utils-growpart \
   compat-openssl10
   ```

5. Go to the `/etc/cloud/cloud.cfg.d/` directory to create cloud-init configuration files:

   ```bash
   cd /etc/cloud/cloud.cfg.d/
   ```

6. Disable the creation of the `ubuntu:` user:

   ```bash
   cat <<EOF > 10_no_default_users.cfg
   users: []
   EOF
   ```

7. Add data sources for cloud-init-datasources:

   ```bash
   cat <<EOF > 91-dib-cloud-init-datasources.cfg
   datasource_list: [  ConfigDrive, Ec2, None ]
   EOF
   ```

8. Disable the warning about using cloud-init and EC2:

   ```bash
   cat <<EOF > 92-ec2-datasource.cfg
   #cloud-config
   datasource:
       Ec2:
           strict_id: false
   EOF
   ```

9. Add boot settings:

   ```bash
   cat <<EOF > 99_boot_routines.cfg
   bootcmd:
       - sed -i '/^;/d' /etc/resolv.conf
   EOF
   ```

10. Prevent cloud-init from disabling EC2 metadata:

    ```bash
    cat <<EOF > 99_enable_ec2.cfg
    disable_ec2_metadata: false
    EOF
    ```

11. Add first-boot settings:

    ```bash
    cat <<EOF > 99_first_boot_routines.cfg
    runcmd:
        - sed -i '/NetworkManager/d' /etc/resolv.conf
        - sed -i '/^search/d' /etc/resolv.conf
        - set-root-pw 2> /dev/null
        - crontab-randomizer
    EOF
    ```

12. Prevent the disabling of root access via SSH:

    ```bash
    cat <<EOF > 99_keep_root_user.cfg
    disable_root: false
    EOF
    ```

13. Change the time zone:

    ```bash
    cat <<EOF > 99_location.cfg
    locale: en_US.UTF-8
    timezone: UTC
    EOF
    ```

14. Add permission for password authentication via SSH:

    ```bash
    cat <<EOF > 99_ssh_settings.cfg
    ssh_pwauth: true
    no_ssh_fingerprints: true
    ssh_deletekeys: true
    EOF
    ```

15. Configure auto-start for services to apply changes and ensure correct operation after the server reboots:

    ```bash
    systemctl enable cloud-init
    systemctl enable cloud-init.service
    systemctl enable cloud-config.service
    systemctl enable cloud-final.service
    systemctl enable qemu-guest-agent.service
    systemctl enable cockpit.socket
    ```

16. [Perform a hard reboot of the server](/cloud-servers/manage/reboot-server.mdx#perform-hard-reboot).

17. [Connect to the cloud server](/cloud-servers/manage/connect-to-server.mdx) again.

    A message will appear stating that the host identity has changed. This means that cloud-init is working successfully when the operating system boots:

    ```bash
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
    Someone could be eavesdropping on you right now (man-in-the-middle attack)!
    It is also possible that a host key has just been changed.
    ```

### 4. Create an image from the cloud server boot disk \{#create-linux-image-from-volume}

1. [Create an image from the cloud server boot disk](/cloud-servers/images/create-image.mdx#create-image-from-volume).

2. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).

3. Add properties for the created image:

   ```bash
   openstack image set --property x_sel_image_owner=Selectel <image>
   openstack image set --property hw_qemu_guest_agent=yes <image>
   ```

   Specify `<image>` — the image ID or name. You can view the list using `openstack image list --private`

4. Optional: after creating the image from the disk, [delete the cloud server](/cloud-servers/manage/delete-server.mdx).

<Formbricks />
