[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Creating a disk > Recovering a disk from an image

# Recovering a disk from an image

{% note info %}

You cannot recover a boot disk of an existing VM from a snapshot or image. However, you can create a new VM to recover a boot disk from a snapshot. To recover the boot disk of an existing VM, use [Yandex Cloud Backup](../../../backup/index.md).

{% endnote %}

To create a disk from an [image](../../concepts/image.md):

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder where you want to create a disk.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/hard-drive.svg) **Disks**.
  1. Click **Create disk**.
  1. Enter a name for the disk.

      * Length: between 3 and 63 characters.
      * It can only contain lowercase Latin letters, numbers, and hyphens.
      * It must start with a letter and cannot end with a hyphen.

  1. Provide a description for the disk, if required.
  1. Select the [availability zone](../../../overview/concepts/geo-scope.md) the disk will reside in.
  1. In the **Contents** field, select `Image` and select an image from the list. Optionally, use the filter.
  1. Set the disk parameters: [disk type](../../concepts/disk.md#disks_types), [disk size](../../concepts/disk.md#maximum-disk-size), and [block size](../../concepts/disk.md#maximum-disk-size).
  1. Optionally, under **Encryption**:
     
       * Select **Encrypted disk**.
       * In the **KMS key** field, select the [key](../../../kms/concepts/key.md) you created earlier. To [create](../../../kms/operations/key.md#create) a new key, click **Create**.
     
       To create an encrypted disk, you need the `kms.keys.user` [role](../../../kms/security/index.md#kms-keys-user) or higher.
     
       {% note warning %}
       
       You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption. You also cannot enable encryption for an existing disk.
       
       {% endnote %}
       
       If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.
       
       {% note alert %}
       
       If you destroy the key or its [version](../../../kms/concepts/version.md) used to encrypt a disk, image, or snapshot, you will irrevocably lose access to the data. For details, see [Destroying key versions](../../../kms/concepts/version.md#version-distruct).
       
       {% endnote %}
  1. Optionally, select or create a [schedule](../../concepts/snapshot-schedule.md) for automatic disk snapshots. For more information on schedule settings, see [this guide](../snapshot-control/create-schedule.md).

      You can create snapshots of network [disks](../../concepts/disk.md#disks_types) and drives, such as HDDs, SSDs, and non-replicated SSDs, as well as ultra high-speed network storages with three replicas (SSD).
      
      For non-replicated SSDs and ultra high-speed network storages with three replicas (SSD), the snapshot time is not determined.
      
      To create snapshots of local disks residing on [dedicated hosts](../../concepts/dedicated-host.md), use [Yandex Cloud Backup](../../../backup/index.md). This service supports Ubuntu, CentOS, CentOS Stream, and Windows Server.

      When creating a disk, you can only select a single snapshot schedule. After the disk is created, you can add a few more schedules by following [this guide](../disk-control/configure-schedule.md#add-schedule).
  1. Optionally, expand the **Additional** section and, in the **Hardware generation** field, select the virtualized hardware [generation](../../concepts/hardware-generations.md#configurations) you want to assign to the new disk:

      * `Gen 1.2 (MBR, BIOS)`: `Gen 1.2`.
      * `Gen 2 (GPT, UEFI)`: `Gen 2`.
      * `Gen 1.1 (MBR, BIOS)`: `Gen 1.1`.

      If you make no assignment, by default the disk will get the same generation assigned as the source image.
  1. Click **Create disk**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. View the description of the CLI command to create a disk:

      ```bash
      yc compute disk create --help
      ```

  1. Get a list of images in the default folder:

      ```bash
      yc compute image list
      ```

      Result:
      ```text
      +----------------------+------------+--------+----------------------+--------+
      |          ID          |    NAME    | FAMILY |     PRODUCT IDS      | STATUS |
      +----------------------+------------+--------+----------------------+--------+
      | fd8ool134m70******** | test-image |        | f2e3eaei7io3******** | READY  |
      | fd8u2d7plgpu******** | image-2    |        |                      | READY  |
      +----------------------+------------+--------+----------------------+--------+
      ```

  1. Select `ID` or `NAME` of the image you need.

  1. Create a disk from the selected image:

      ```bash
      yc compute disk create \
        --name <disk_name> \
        --source-image-name <source_image_name> \
        --zone <availability_zone> \
        --description <text_description_of_disk> \
        --hardware-generation-id <hardware_generation> \
        --hardware-features pci_topology=<PCI_topology> \
        --kms-key-id <key_ID>
      ```

      Where:
      * `--name`: Disk name. The naming requirements are as follows:

          * Length: between 3 and 63 characters.
          * It can only contain lowercase Latin letters, numbers, and hyphens.
          * It must start with a letter and cannot end with a hyphen.

      * `--source-image-name`: Source image name. Instead of a name, you can provide the source image ID in the `--source-image-id` parameter.
      * `--zone`: [Availability zone](../../../overview/concepts/geo-scope.md) of the new disk.
      * `--description`: Text description of the new disk. This is an optional setting.
      * `--hardware-generation-id`: Virtualized hardware [generation](../../concepts/hardware-generations.md#configurations) assigned to the disk. This is an optional setting. The possible values are:

          * `legacy`: `Gen 1`. If you select this generation, you can also specify the PCI topology in the `--hardware-features` parameter.
          * `generation2`: `Gen 2`. If you select this generation, you do not need to specify `--hardware-features`.

          If not specified, the disk will get the same hardware generation assigned as the source image.
      * `--hardware-features`: Additional settings for `Gen 1`. This is an optional setting. The possible values are:

          * `pci_topology=v1`: `PCI_TOPOLOGY_V1` topology.
          * `pci_topology=v2`: Adopts the `PCI_TOPOLOGY_V2` topology.

          If the source image has `Gen 2` assigned, by default the new disk will get `--hardware-features` set to `pci_topology=v1`.

          If the source image has `Gen 1` assigned, by default the new disk will get the same `--hardware-features` value as the source image.
      * `--kms-key-id`: ID of the Yandex Key Management Service [symmetric encryption key](../../../kms/concepts/key.md) for creating an encrypted disk. This is an optional setting.

          To create an encrypted disk, you need the `kms.keys.user` [role](../../../kms/security/index.md#kms-keys-user) or higher.
        
          {% note warning %}
          
          You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption. You also cannot enable encryption for an existing disk.
          
          {% endnote %}

          If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.
          
          {% note alert %}
          
          If you destroy the key or its [version](../../../kms/concepts/version.md) used to encrypt a disk, image, or snapshot, you will irrevocably lose access to the data. For details, see [Destroying key versions](../../../kms/concepts/version.md#version-distruct).
          
          {% endnote %}

      Result:

      ```text
      done (50s)
      id: epdoljps3ljd********
      folder_id: b1gt6g8ht345********
      created_at: "2025-06-23T17:25:56Z"
      name: first-disk
      description: my very first disk
      type_id: network-hdd
      zone_id: ru-central1-a
      size: "21474836480"
      block_size: "4096"
      product_ids:
        - f2ercusam4no********
      status: READY
      source_image_id: fd8it9g4ui2l********
      disk_placement_policy: {}
      hardware_generation:
        legacy_features:
          pci_topology: PCI_TOPOLOGY_V2
      ```

      For more information about the `yc compute disk create` command, see the [CLI reference](../../../cli/cli-ref/compute/cli-ref/disk/create.md).

  1. Get a list of disks in the default folder:

      ```bash
      yc compute disk list
      ```
      
      Result:
      
      ```text
      +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
      |          ID          |     NAME     |    SIZE     |       ZONE        | STATUS |     INSTANCE IDS     | PLACEMENT GROUP | DESCRIPTION |
      +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
      | a7lqgbt0bb9s******** | first-disk   | 20401094656 |   ru-central1-a   | READY  | a7lcvu28njbh******** |                 |             |
      | a7lv5j5hm1p1******** | second-disk  | 21474836480 |   ru-central1-a   | READY  |                      |                 |             |
      +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
      ```

      Get the same list with more details in YAML format:

      ```bash
      yc compute disk list --format yaml
      ```

      Result:
      ```text
      - id: epdoljps3ljd********
        folder_id: b1gt6g8ht345********
        created_at: "2025-06-23T17:25:56Z"
        name: first-disk
        description: my very first disk
        type_id: network-hdd
        zone_id: ru-central1-a
        size: "21474836480"
        block_size: "4096"
        product_ids:
          - f2ercusam4no********
        status: READY
        source_image_id: fd8it9g4ui2l********
        disk_placement_policy: {}
        hardware_generation:
          legacy_features:
            pci_topology: PCI_TOPOLOGY_V2
      - id: epd8lmcncidv********
        folder_id: b1gt6g8ht345********
        created_at: "2025-06-23T06:32:26Z"
        name: second-disk
        type_id: network-ssd
        zone_id: ru-central1-a
        size: "21474836480"
        block_size: "4096"
        product_ids:
          - f2evcrm9ti79********
        status: READY
        source_image_id: fd80j21lmqar********
        instance_ids:
          - epdm2ene322e********
        disk_placement_policy: {}
        hardware_generation:
          legacy_features:
            pci_topology: PCI_TOPOLOGY_V1
      ```

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  1. Define the parameters of the `yandex_compute_disk` resource in the configuration file.

      Here is an example of the configuration file structure:
     
      ```hcl
      resource "yandex_compute_disk" "my-disk" {
        name           = "<disk_name>"
        zone           = "<availability_zone>"
        image_id       = "<image_ID>"
        hardware_generation {
          legacy_features {
            pci_topology = "<PCI_topology>"
          }
        }
      }
      ```

      Where:
      * `name`: Disk name. The naming requirements are as follows:

          * Length: between 3 and 63 characters.
          * It can only contain lowercase Latin letters, numbers, and hyphens.
          * It must start with a letter and cannot end with a hyphen.

      * `zone`: [Availability zone](../../../overview/concepts/geo-scope.md) of the new disk.
      * `image_id`: ID of the image you are creating the disk based on.
      * `hardware_generation`: Block of settings describing the virtualized hardware [generation](../../concepts/hardware-generations.md#configurations) assigned to the disk. This is an optional setting. It includes the following blocks of settings:

          * `legacy_features`: Settings with the description of parameters for `Gen 1`:
          
              * `pci_topology`: Selecting the PCI topology. The possible values are:
          
                  * `PCI_TOPOLOGY_V1`
                  * `PCI_TOPOLOGY_V2`
          
              The `legacy_features` and `generation2_features` sections are mutually exclusive.
          * `generation2_features`: Settings for `Gen 2`. If you select `Gen 2`, you do not need to specify any additional settings.
          
              The `generation2_features` and `legacy_features` sections are mutually exclusive.

          {% note info %}

          If the `hardware_generation` settings are not specified, the disk will get the same hardware generation assigned as the source image.

          {% endnote %}

      For more information about `yandex_compute_disk`, see [this provider guide](../../../terraform/resources/compute_disk.md).

  1. Make sure the configuration files are correct.

     1. In the terminal, navigate to the directory where you created your configuration file.
     1. Run a check using this command:

        ```bash
        terraform plan
        ```

     If the configuration is correct, the terminal will display a list of the resources and their settings. Otherwise, Terraform will show any detected errors. 

  1. Deploy the cloud resources.

     1. If the configuration is correct, run this command:

        ```bash
        terraform apply
        ```

     1. Confirm creating the resources.

     This will create all the resources you need in the specified folder. You can check the new resources and their settings using the [management console](https://console.yandex.cloud).

- API {#api}

  1. Get a list of images using the [list](../../api-ref/Image/list.md) REST API method for the [Image](../../api-ref/Image/index.md) resource or the [ImageService/List](../../api-ref/grpc/Image/list.md) gRPC API call.
  1. Create a disk using the [create](../../api-ref/Disk/create.md) REST API method for the [Disk](../../api-ref/Disk/index.md) resource or the [DiskService/Create](../../api-ref/grpc/Disk/create.md) gRPC API call. In your request, specify the source image ID, and optionally the required hardware [generation](../../concepts/hardware-generations.md#configurations) in the [`hardwareGeneration`](../../api-ref/Disk/create.md#yandex.cloud.compute.v1.HardwareGeneration) object ([`hardware_generation`](../../api-ref/grpc/Disk/create.md#yandex.cloud.compute.v1.HardwareGeneration) if using the gRPC API).

{% endlist %}

Once created, the disk will get the `CREATING` status. Wait until the disk status changes to `READY` before using it.


#### See also {#see-also}

* [Creating a VM from a custom image](../vm-create/create-from-user-image.md)
* [Attaching a disk to a VM and mounting partitions](../vm-control/vm-attach-disk.md)
* [Yandex Cloud Backup overview](../../../backup/concepts/index.md)