[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Desktop](../../index.md) > [Step-by-step guides](../index.md) > Images > Creating a Linux image from a Compute Cloud VM

# Creating an image from a Compute Cloud Linux instance

In Cloud Desktop, you can create desktops from pre-installed [system images](../../concepts/images.md) or your own [custom images](../../concepts/images.md#custom-images).

Custom images can be [Windows](create-from-windows.md) or Linux-based.

A Linux image is created from a Compute Cloud [instance](../../../compute/concepts/vm.md).

To add a custom Linux image to Cloud Desktop:

1. [Create](../../../compute/operations/vm-create/create-linux-vm.md) or select a previously created VM instance with the following parameters:
   * Access: Via an **SSH key**. Cloud Desktop does not support OS Login access.
   * Connecting to the internet to install additional software.

1. Configure the instance to create the image you need.
1. Configure remote [RDP](https://ru.wikipedia.org/wiki/Remote_Desktop_Protocol) access:
   1. Install `xrdp` and `xorgxrdp` or other relevant software.
   
        {% note info %}
        
        Cloud Desktop connects to a remote desktop over IPv6 using port `3389`. Make sure `xrdp` supports IPv6. To do it, after you install `xrdp`, check that it listens IPv6 addresses, e.g., by running `netstat -tulpn | grep xrdp`. The command output should contain IPv6 addresses, e.g., `::1` or `:::3389`. If there are none, set up IPv6 in the `/etc/xrdp/xrdp.ini` configuration file.

        {% endnote %}

   1. Install system audio management packages to enable audio and a microphone. For example, install `pipewire-module-xrdp` or `pulseaudio-module-xrdp` for `xrdp`.
   
    Example of RDP and audio configuration for Debian 12:

    ```bash
    sudo apt-get update
    sudo apt-get install -y xfce4 pipewire pipewire-pulse xorgxrdp xrdp pipewire-module-xrdp
    sudo systemctl enable xrdp
    sudo systemctl enable xrdp-sesman
    ```

1. Set the incoming connections on all network interfaces for:
   * RDP: To TCP port `3389`.
   * Yandex Cloud Desktop Agent: To TCP port `5050`.

1. Check VM availability over RDP.

1. Install the Yandex Cloud Desktop agent for Linux using the following series of commands:
  
    ```bash
    WORKDIR=$(mktemp -d -p $HOME)
    cd ${WORKDIR}
    curl -sSL https://storage.yandexcloud.net/yandexcloud-vdi-agent/install.sh > desktop-agent-install.sh
    chmod +x desktop-agent-install.sh
    ./desktop-agent-install.sh -i ${WORKDIR}
    sudo mkdir -p /opt/yandex-cloud/cloud-desktops
    sudo rm -rf /opt/yandex-cloud/cloud-desktops/desktopagent
    sudo cp ${WORKDIR}/bin/desktopagent /opt/yandex-cloud/cloud-desktops/
    sudo chown root:root /opt/yandex-cloud/cloud-desktops/desktopagent
    sudo chmod +x /opt/yandex-cloud/cloud-desktops/desktopagent
    ```

1. Enable agent autorun on VM OS boot.

    Example of enabling autorun for an OS with the SystemD init system (Ubuntu, Debian, CentOS, Fedora, openSUSE, other):

    ```bash
    sudo cat >/etc/systemd/system/desktop-agent.service <<EOF
    [Unit]
    Description=Yandex Cloud Desktop Agent
    Wants=networking.service
    After=networking.service cloud-init.service

    ConditionFileIsExecutable=/opt/yandex-cloud/cloud-desktops/desktopagent

    [Service]
    Type=simple
    ExecStart=/opt/yandex-cloud/cloud-desktops/desktopagent start --log-level debug
    Restart=always
    RestartSec=30

    [Install]
    WantedBy=multi-user.target cloud-init.target
    EOF

    sudo systemctl daemon-reload
    sudo systemctl enable desktop-agent.service
    ```


1. Before creating a boot disk image, clean the instance’s OS from the data you do not need. For example, in distributions with the `apt` package manager, you can clear the cache:

    ```bash
    sudo apt-get clean
    ```

1. Create a VM disk image.

    {% list tabs group=instructions %}

    - Management console {#console}

      1. In the [management console](https://console.yandex.cloud), navigate to the folder containing the VM.
      1. Navigate to **Compute Cloud**.
      1. Next to your instance, click ![image](../../../_assets/console-icons/ellipsis.svg) → **Stop**.
      1. In the left-hand panel, select ![image](../../../_assets/console-icons/hard-drive.svg) **Disks**.
      1. In the line with the instance boot disk, click ![image](../../../_assets/console-icons/ellipsis.svg) → **Create image**.
      1. Enter a name for the image and provide some description, if needed.
      1. Click **Create**.

    {% endlist %}

1. Add this image to Cloud Desktop:

    {% list tabs group=instructions %}

    - Management console {#console}

      1. In the [management console](https://console.yandex.cloud), select the folder that contains the VM and a desktop will be created in. 
      1. Navigate to **Cloud Desktop**.
      1. In the left-hand panel, select ![image](../../../_assets/console-icons/layers.svg) **Images**.
      1. Click **Add image**.
      1. In the **Image source** field, select `Compute Cloud`.
      1. In the **Image in Compute Cloud** field, select the previously created image.
      1. Specify the image name.
      1. Click **Add**.

    {% endlist %}

Once the image is created, you can use it as a boot disk image for desktop groups.

If you no longer need the image and the instance, delete them to avoid paying for them:

* [Deleting a VM](../../../compute/operations/vm-control/vm-delete.md)
* [Deleting a disk image](../../../compute/operations/image-control/delete.md)