[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Creating a VM > Creating a VM with Gen 2 hardware

# Creating a VM with Gen 2 hardware

The [VM](../../concepts/vm.md) runs on virtualized hardware of the [generation](../../concepts/hardware-generations.md) [assigned](../../concepts/hardware-generations.md#locking-generations) to the medium (i.e., [image](../../concepts/image.md), [snapshot](../../concepts/snapshot.md), or [disk](../../concepts/disk.md)) the VM was created based on.

Therefore, to create a VM running on `Gen 2` hardware, you must first create a medium with `Gen 2` assigned, and then create your [VM](#create-vm) from this medium.

To create a VM running on virtualized `Gen 2` hardware, proceed as follows:

1. Prepare a medium of one of these types: [image](#create-image), [snapshot](#create-snapshot), or [disk](#create-disk).
1. [Create a VM from the medium you prepared](#create-vm).

## Create an image with the Gen 2 hardware generation assigned {#create-image}

You can create a VM image with the `Gen 2` hardware generation assigned either from your own image [pre-uploaded](#upload-own-image) to Yandex Cloud or from [existing](#create-image-from-existing-source) images, snapshots, and disks available in Yandex Cloud.

### Upload your disk image to Yandex Cloud {#upload-own-image}

You can upload your own UEFI and GPT-enabled VM image to Compute Cloud to create VMs running on `Gen 2` hardware. You can create an image in Compute Cloud from a prepared image file uploaded to [Yandex Object Storage](../../../storage/index.md).

#### Prepare an image file {#prepare-file}

For boot disk images, the following requirements apply:

* The `virtio-net`, `virtio-blk`, and `virtio-pci` drivers are installed. If you are going to attach [file storages](../../concepts/filesystem.md) to your [VM](../../concepts/vm.md), you also need to install the `virtiofs` driver. For details, see [this guide](../image-create/custom-image.md#virtio).
* The `ttyS0` terminal (COM1) is configured as the [serial console](../../concepts/serial-console.md). For details, see [this guide](../image-create/custom-image.md#serial-console).
* The network interface runs correctly when starting the VM and gets the [IP address](../../../vpc/concepts/address.md) via DHCP.
* The `cloud-init` package is installed and configured to work with our [metadata service](../vm-info/get-info.md#inside-instance). Run `sudo yum install cloud-init` to install the package for CentOS or `sudo apt update && sudo apt install -y cloud-init` to install it for Debian or Ubuntu.
* For an image based on an AMI, cloud platform verification for the VM instance is disabled in the `cloud-init` settings. For details, see [this guide](../image-create/custom-image.md#ec2).
* The system firewall is configured to only allow the minimum ports required for your applications to run securely and the SSH port (by default, 22 TCP).
* The SSH server starts automatically at VM startup.
* The services running your application are resilient to VM reboots.

* Use [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) partitioning for the boot disk.

* The disk is mounted by its UUID rather than by name.
* The file system is not encrypted.

Supported formats: `Qcow2`, `VMDK`, `RAW`, and `VHD`.

For setup instructions, see [Setting up a custom disk image](../image-create/custom-image.md).

#### Upload the image file to Object Storage {#upload-file}

Upload your image file to Object Storage and get a shareable link:

1. If you have no [Object Storage bucket](../../../storage/concepts/bucket.md) yet, [create](../../../storage/operations/buckets/create.md) one with restricted access.
1. Upload your image to the bucket via the [management console](../../../storage/operations/objects/upload.md), [AWS CLI](../../../storage/tools/aws-cli.md), or [WinSCP](../../../storage/tools/winscp.md). In Object Storage terminology, your uploaded image will be called an _object_.
1. [Get](../../../storage/operations/objects/link-for-download.md) a signed [link](../../../storage/concepts/pre-signed-urls.md) to download the image from the bucket. Use this link when creating an image in Compute Cloud.

#### In Compute Cloud, create an image with the Gen 2 hardware generation assigned {#create-image-from-link}

To create a new image using the link you got in [Object Storage](../../../storage/index.md):

{% list tabs group=instructions %}

- Management console {#console}

  1. In the management console, select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) where you want to create the image.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![layers](../../../_assets/console-icons/layers.svg) **Images**.
  1. Click **Upload image**, and in the window that opens:

      1. In the **Name** field, enter a name for the image. 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.

      1. Optionally, in the **Description** and **Labels** fields, add a description and [labels](../../../resource-manager/concepts/labels.md) for the new image.
      1. In the **Link to image in Object Storage** field, paste the image file link you got in Object Storage earlier.
      1. In the **Hardware generation** field, select the `Gen 2 (GPT, UEFI)` [hardware generation](../../concepts/hardware-generations.md).
      1. To enable image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment, expand **Additional** and enable the **Optimization** option.
      1. Click **Upload**.

- 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. See the description of the Yandex Cloud CLI command for creating an image:

      ```bash
      yc compute image create --help
      ```
  1. To create a new image with the `Gen 2` hardware generation assigned using a link, run this command:

      ```bash
      yc compute image create \
        --name <image_name> \
        --source-uri "<image_URL>" \
        --hardware-generation-id generation2 \
        --pooled
      ```

      Where:
      * `--name`: Name to assign to the image. 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-uri`: Image link you got in Object Storage.
      * `--pooled`: Enables image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment. This is an optional setting. By default, the optimization is disabled.

      Result:

      ```bash
      done (12s)
      id: fd86a13e6ro9********
      folder_id: b1gt6g8ht345********
      created_at: "2025-12-05T16:26:46Z"
      name: my-own-gen2-image
      storage_size: "1891631104"
      min_disk_size: "1891631104"
      status: READY
      os:
        type: LINUX
      hardware_generation:
        generation2_features: {}
      ```

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

- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

  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.

  To create an image:
  1. Specify the parameters of the `yandex_compute_image` resource in the configuration file.

      Here is an example of the configuration file structure:

      ```hcl
      resource "yandex_compute_image" "image-1" {
        name                 = "<image_name>"
        source_url           = "<image_link>"
        pooled               = "true|false"

        hardware_generation {
          generation2_features {}
        }
      }
      ```

      Where:
      * `name`: Name to assign to the image. 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_url`: Image link in Object Storage.
      * `pooled`: Enables image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment. The possible values are:
      
          * `true`: Optimization enabled.
          * `false`: Optimization disabled.
          
          This is an optional setting. By default, optimization is disabled.

      For more information about `yandex_compute_image` properties, see [this Terraform provider guide](../../../terraform/resources/compute_image.md).
  1. Create the resources:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.

      Terraform will create all the required resources. You can check new resources in the [management console](https://console.yandex.cloud) or using this CLI command:

      ```bash
      yc compute image list
      ```

- API {#api}

  Use the [create](../../api-ref/Image/create.md) REST API method for the [Image](../../api-ref/Image/index.md) resource or the [ImageService/Create](../../api-ref/grpc/Image/create.md) gRPC API call.

  For example, to create an image with the `Gen 2` hardware generation assigned using REST API:

  1. Install [cURL](https://curl.haxx.se).
  1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) used for API authentication:
      * [Guide](../../../iam/operations/iam-token/create.md) for a Yandex account user
      * [Guide](../../../iam/operations/iam-token/create-for-sa.md) for a [service account](../../../iam/concepts/users/service-accounts.md)
      * [Guide](../../../iam/operations/iam-token/create-for-federation.md) for a federated account
      * [Guide](../../../iam/operations/iam-token/create-for-local.md) for a local account
  1. For your request to run smoothly, save the IAM token you got to the `IAM_TOKEN` environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token_contents>"
      ```
  1. Create a file containing the body of your image create request (e.g., `body.json`) and add the following code to it:

      **body.json**

      ```json
      {
        "folderId": "<folder_ID>",
        "name": "<image_name>",
        "uri": "<link_to_uploaded_image>",
        "pooled": "true|false",
        "hardwareGeneration": {
          "generation2Features": {}
        }
      }
      ```

      Where:

      * `folderId`: [ID](../../../resource-manager/operations/folder/get-id.md) of the image folder.
      * `name`: Image name. Follow these naming requirements:

          * 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.

      * `uri`: Image link in Object Storage.
      * `pooled`: Enables [image optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment. The possible values are:
      
          * `true`: Optimization enabled.
          * `false`: Optimization disabled.

          This is an optional setting. By default, optimization is disabled.

  1. Run this http request:

      ```bash
      curl \
        --request POST \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer ${IAM_TOKEN}" \
        --data '@body.json' \
        https://compute.api.cloud.yandex.net/compute/v1/images
      ```

      Result:

      ```text
      {
      "done": false,
      "metadata": {
        "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateImageMetadata",
        "imageId": "fd8g5p4hllq8********"
      },
      "id": "fd8m1tfm92kr********",
      "description": "Create image",
      "createdAt": "2025-12-05T16:41:54.452564354Z",
      "createdBy": "ajeol2afu1js********",
      "modifiedAt": "2025-12-05T16:41:54.452564354Z"
      }
      ```

{% endlist %}

After you create the image, you can [delete](../../../storage/operations/objects/delete.md) the original file from the bucket.

### Creating a disk image with the Gen 2 hardware generation assigned from another image, snapshot, or disk {#create-image-from-existing-source}

By default, a newly created image is assigned the [hardware generation](../../concepts/hardware-generations.md) [assigned](../../concepts/hardware-generations.md#locking-generations) to the original image, snapshot, or disk the image was created from. However, you can explicitly specify a hardware generation different from that assigned to the original image, snapshot, or disk.

[Public images](../../concepts/image.md#public) available for installation on VMs in [Yandex Cloud Marketplace](https://yandex.cloud/en/marketplace) get `Gen 1.1` or `Gen 1.2` assigned by default. At the same time, some public images (e.g., those running Linux [Ubuntu 24.04 LTS](https://yandex.cloud/en/marketplace/products/yc/ubuntu-24-04-lts)) support `Gen 2` hardware with [UEFI](https://en.wikipedia.org/wiki/UEFI) boot and the [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) partition table; you can use such images to create a disk or an image of your own with `Gen 2` assigned. Other public images do not support UEFI boot, so you cannot use them to create a VM running on `Gen 2` hardware.

{% note info %}

You can create a new image with the `Gen 2` hardware generation assigned from a [public image](../../concepts/image.md#public) in [Yandex Cloud Marketplace](https://yandex.cloud/en/marketplace) only with the help the [Yandex Cloud CLI](../../../cli/cli-ref/compute/cli-ref/image/create.md), [Terraform](../../../terraform/resources/compute_image.md), or [API](../../api-ref/Image/create.md).

{% endnote %}

To create an image from an existing [image](../../concepts/image.md), [snapshot](../../concepts/snapshot.md), or [disk](../../concepts/disk.md):

{% list tabs group=instructions %}

- Management console {#console}

  1. In the management console, select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) where you want to create an image.
  1. Navigate to **Compute Cloud**.
  1. Depending on the source you want to create the new image from, select ![archive](../../../_assets/console-icons/archive.svg) **Disks and storages**, ![picture](../../../_assets/console-icons/picture.svg) **Snapshots**, or ![layers](../../../_assets/console-icons/layers.svg) **Images** in the left-hand panel.
  1. Depending on the source type you selected, in the list that opens, click ![ellipsis](../../../_assets/console-icons/ellipsis.svg) next to the image, snapshot, or disk, and select ![layers](../../../_assets/console-icons/layers.svg) **Create image**. In the window that opens:

      1. In the **Name** field, enter a name for the new image. 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.

      1. Optionally, in the **Description** and **Labels** fields, add a description and [labels](../../../resource-manager/concepts/labels.md) for the new image.
      1. Expand the **Additional** section and select `Gen 2 (GPT, UEFI)` in the **Hardware generation** field.

          {% note alert %}
          
          Make sure the source operating system boot loader supports [UEFI](https://en.wikipedia.org/wiki/UEFI) boot mode and the [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.
          
          {% endnote %}

      1. To enable image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment, enable the **Optimization** option.
      1. Click **Create**.

- 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.

  {% note alert %}
  
  Make sure the source operating system boot loader supports [UEFI](https://en.wikipedia.org/wiki/UEFI) boot mode and the [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.
  
  {% endnote %}

  1. See the description of the Yandex Cloud CLI command for creating an image:

      ```bash
      yc compute image create --help
      ```

  1. To create a new image with the `Gen 2` hardware generation assigned from an existing [image](../../concepts/image.md), [snapshot](../../concepts/snapshot.md), or [disk](../../concepts/disk.md), run this command:

      ```bash
      yc compute image create \
        --name <image_name> \
        --source-image-id <source_image_ID> \
        --source-snapshot-id <source_snapshot_ID> \
        --source-disk-id <source_disk_ID> \
        --hardware-generation-id generation2 \
        --pooled
      ```

      Where:
      * `--name`: Name to assign to the image. 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.

      * Selecting a source for your image:

          * `--source-image-id`: Source image ID. Instead of the ID, you can provide its name in `--source-image-name`.
          * `--source-snapshot-id`: Source snapshot ID. Instead of the ID, you can provide its name in `--source-snapshot-name`.
          * `--source-disk-id`: Source disk ID. Instead of the ID, you can provide its name in `--source-disk-name`.

          {% note info %}

          `--source-image-id`, `--source-image-name`, `--source-snapshot-id`, `--source-snapshot-name`, `--source-disk-id`, and `--source-disk-name` are mutually exclusive: you can use only one of them in the command.

          {% endnote %}

      * `--pooled`: Enables image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment. This is an optional setting. By default, the optimization is disabled.

      Result:

      ```text
      done (9s)
      id: fd86kup8c7pa********
      folder_id: b1gt6g8ht345********
      created_at: "2025-12-05T06:57:09Z"
      name: my-sample-gen2-image
      storage_size: "9877585920"
      min_disk_size: "21474836480"
      product_ids:
        - f2ercusam4no********
      status: READY
      os:
        type: LINUX
      hardware_generation:
        generation2_features: {}
      ```

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

- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

  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_image` resource in the configuration file.

      Here is an example of the configuration file structure:

      ```hcl
      resource "yandex_compute_image" "image-1" {
        name                 = "<image_name>"
        source_image         = "<source_image_ID>"
        source_snapshot      = "<source_snapshot_ID>"
        source_disk          = "<source_disk_ID>"
        pooled               = "true|false"

        hardware_generation {
          generation2_features {}
        }
      }
      ```

      {% note alert %}
      
      Make sure the source operating system boot loader supports [UEFI](https://en.wikipedia.org/wiki/UEFI) boot mode and the [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.
      
      {% endnote %}

      Where:
      * `name`: Name to assign to the image. 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.

      * Selecting a source for your image:

          * `source_image`: Source image ID.
          * `source_snapshot`: Source snapshot ID.
          * `source_disk`: Source disk ID.

          {% note info %}

          `source_image`, `source_snapshot`, and `source_disk` are mutually exclusive: you can use only one of them in the configuration file.

          {% endnote %}

      * `pooled`: Enables image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment. The possible values are:
      
          * `true`: Optimization enabled.
          * `false`: Optimization disabled.
          
          This is an optional setting. By default, optimization is disabled.

          For more information about `yandex_compute_image` properties, see [this Terraform provider guide](../../../terraform/resources/compute_image.md).
          
  1. Create the resources:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.

      Terraform will create all the required resources. You can check new resources in the [management console](https://console.yandex.cloud) or using this CLI command:

      ```bash
      yc compute image list
      ```

- API {#api}

  Use the [create](../../api-ref/Image/create.md) REST API method for the [Image](../../api-ref/Image/index.md) resource or the [ImageService/Create](../../api-ref/grpc/Image/create.md) gRPC API call.

  For example, to create an image with the `Gen 2` hardware generation assigned using REST API:

  1. Install [cURL](https://curl.haxx.se).
  1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) used for API authentication:
      * [Guide](../../../iam/operations/iam-token/create.md) for a Yandex account user
      * [Guide](../../../iam/operations/iam-token/create-for-sa.md) for a [service account](../../../iam/concepts/users/service-accounts.md)
      * [Guide](../../../iam/operations/iam-token/create-for-federation.md) for a federated account
      * [Guide](../../../iam/operations/iam-token/create-for-local.md) for a local account
  1. For your request to run smoothly, save the IAM token you got to the `IAM_TOKEN` environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token_contents>"
      ```
  1. Create a file containing the body of your image create request (e.g., `body.json`) and add the following code to it:

      **body.json**

      ```json
      {
        "folderId": "<folder_ID>",
        "name": "<image_name>",
        "imageId": "<source_image_ID>",
        "snapshotId": "<source_snapshot_ID>",
        "diskId": "<source_disk_ID>",
        "pooled": "true|false",
        "hardwareGeneration": {
          "generation2Features": {}
        }
      }
      ```

      Where:

      * `folderId`: [ID](../../../resource-manager/operations/folder/get-id.md) of the image folder.
      * `name`: Image 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.

      {% note alert %}
      
      Make sure the source operating system boot loader supports [UEFI](https://en.wikipedia.org/wiki/UEFI) boot mode and the [GPT](https://en.wikipedia.org/wiki/GUID_Partition_Table) partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.
      
      {% endnote %}

      * Selecting a source for your image:

          * `imageId`: Source image ID.
          * `snapshotId`: Source snapshot ID.
          * `diskId`: Source disk ID.

          {% note info %}

          The `imageId`, `snapshotId`, and `diskId` fields are mutually exclusive: you can use only one of them in the request.

          {% endnote %}

      * `pooled`: Enables image [optimization](../../concepts/image.md#images-optimized-for-deployment) for deployment. The possible values are:
      
          * `true`: Optimization enabled.
          * `false`: Optimization disabled.

          This is an optional setting. By default, optimization is disabled.

  1. Run this http request:

      ```bash
      curl \
        --request POST \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer ${IAM_TOKEN}" \
        --data '@body.json' \
        https://compute.api.cloud.yandex.net/compute/v1/images
      ```

      Result:

      ```text
      {
      "done": false,
      "metadata": {
        "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateImageMetadata",
        "imageId": "fd8j3jind4ij********"
      },
      "id": "fd8a7eged70b********",
      "description": "Create image",
      "createdAt": "2025-12-05T08:51:44.937021154Z",
      "createdBy": "ajeol2afu1js********",
      "modifiedAt": "2025-12-05T08:51:44.937021154Z"
      }
      ```

{% endlist %}

This will create an image with the `Gen 2` virtualized hardware [generation](../../concepts/hardware-generations.md) assigned.

## Create a disk snapshot with the Gen 2 hardware generation assigned {#create-snapshot}

You can snapshot the boot disk of an existing VM running on `Gen 1.1` or `Gen 1.2` generation virtualized hardware and assign the `Gen 2` generation hardware to this snapshot.

### Prepare the disk for a snapshot {#prepare-for-making-snapshot}

A disk snapshot only contains the data that was written to the disk at the time its snapshot was created. If the disk is attached to a running VM, the OS and app cache will not be included in the snapshot.

To ensure the snapshot data integrity:

{% list tabs group=operating_system %}

- Linux {#linux}

  1. Stop all disk write operations in applications.

  1. Write the OS cache to the disk:

      ```bash
      sync
      ```

  1. Freeze the file system:

      ```bash
      sudo fsfreeze --freeze <mount_point>
      ```
      Where `--freeze` is the parameter to freeze the file system. Replace `<mount_point>` with the folder where the file system is mounted, e.g., `/mnt/vdc2`.

  1. Create a snapshot by following the steps [below](#create).

  1. Unfreeze the file system:

      ```bash
      sudo fsfreeze --unfreeze <mount_point>
      ```
      Where `--unfreeze` is the parameter to unfreeze the file system. Replace `<mount_point>` with the folder where the file system is mounted, e.g., `/mnt/vdc2`.

- Other operating systems {#other}

  1. Stop the VM (see [Stopping](../vm-control/vm-stop-and-start.md#stop)).
  1. Wait until the VM status changes to `STOPPED`.

{% endlist %}

### Create a snapshot {#create-snapshot-operation}

To create a disk snapshot with the `Gen 2` hardware generation assigned:

{% note info %}

You can assign to a snapshot a generation different from the one assigned to the source disk only using the [Yandex Cloud CLI](../../../cli/cli-ref/compute/cli-ref/snapshot/create.md), [Terraform](../../../terraform/resources/compute_snapshot.md), or [API](../../api-ref/Snapshot/create.md).

{% endnote %}

{% list tabs group=instructions %}

- 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. See the description of the CLI command for creating snapshots:

      ```bash
      yc compute snapshot create --help
      ```

  1. Create a snapshot in the default folder:

      ```bash
      yc compute snapshot create \
        --name <snapshot_name> \
        --disk-id <source_disk_ID> \
        --hardware-generation-id generation2
      ```

      Where:
      * `--name`: Snapshot 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.

      * `--disk-id`: ID of the disk you are creating the snapshot for. Instead of the ID, you can provide its name in `--disk-name`.

      Result:

      ```text
      done (18s)
      id: fd8jnmpan5ff********
      folder_id: b1gt6g8ht345********
      created_at: "2025-12-05T14:10:15Z"
      name: my-gen2-snapshot
      storage_size: "3632267264"
      disk_size: "21474836480"
      product_ids:
        - f2ebiogvi127********
      status: READY
      source_disk_id: epd89t47vnhd********
      hardware_generation:
        generation2_features: {}
      ```

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

- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

  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_snapshot` resource in the configuration file.

      Here is an example of the configuration file structure:
      
      ```hcl
      resource "yandex_compute_snapshot" "snapshot-1" {
        name                 = "<snapshot_name>"
        source_disk_id       = "<disk_ID>"
        hardware_generation {
          generation2_features {}
        }
      }
      ```

      Where:
      * `name`: Name to assign to the snapshot. 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_disk_id`: ID of the disk you are creating the snapshot for.

      For more information about `yandex_compute_snapshot` properties, see [this Terraform provider guide](../../../terraform/resources/compute_snapshot.md).
          
  1. Create the resources:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.

      Terraform will create all the required resources. You can check new resources in the [management console](https://console.yandex.cloud) or using this CLI command:

      ```bash
      yc compute snapshot list
      ```

- API {#api}

  Use the [create](../../api-ref/Snapshot/create.md) REST API method for the [Snapshot](../../api-ref/Snapshot/index.md) resource or the [SnapshotService/Create](../../api-ref/grpc/Snapshot/create.md) gRPC API call.

  For example, to create a snapshot with the `Gen 2` hardware generation assigned using REST API:

  1. Install [cURL](https://curl.haxx.se).
  1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) used for API authentication:
      * [Guide](../../../iam/operations/iam-token/create.md) for a Yandex account user
      * [Guide](../../../iam/operations/iam-token/create-for-sa.md) for a [service account](../../../iam/concepts/users/service-accounts.md)
      * [Guide](../../../iam/operations/iam-token/create-for-federation.md) for a federated account
      * [Guide](../../../iam/operations/iam-token/create-for-local.md) for a local account
  1. For your request to run smoothly, save the IAM token you got to the `IAM_TOKEN` environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token_contents>"
      ```
  1. Create a file containing the body of your snapshot create request (e.g., `body.json`), and add the following code to it:

      **body.json**

      ```json
      {
        "folderId": "<folder_ID>",
        "name": "<snapshot_name>",
        "diskId": "<disk_ID>",
        "hardwareGeneration": {
          "generation2Features": {}
        }
      }
      ```

      Where:

      * `folderId`: [ID](../../../resource-manager/operations/folder/get-id.md) of the snapshot folder.
      * `name`: Snapshot 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.

      * `diskId`: ID of the [disk](../../concepts/disk.md) you are making the snapshot for.

  1. Run this http request:

      ```bash
      curl \
        --request POST \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer ${IAM_TOKEN}" \
        --data '@body.json' \
        https://compute.api.cloud.yandex.net/compute/v1/snapshots
      ```

      Result:

      ```text
      {
      "done": false,
      "metadata": {
        "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateSnapshotMetadata",
        "snapshotId": "fd8apannhdo9********",
        "diskId": "epd89t47vnhd********"
      },
      "id": "epd473ndlm58********",
      "description": "Create snapshot",
      "createdAt": "2025-12-05T14:43:02.803028670Z",
      "createdBy": "ajeol2afu1js********",
      "modifiedAt": "2025-12-05T14:43:02.803028670Z"
      }
      ```

{% endlist %}

This will create a disk snapshot with the `Gen 2` virtualized hardware [generation](../../concepts/hardware-generations.md) assigned.


## Create a disk with the Gen 2 hardware generation assigned {#create-disk}

By default, a newly created disk is assigned the [hardware generation](../../concepts/hardware-generations.md) [assigned](../../concepts/hardware-generations.md#locking-generations) to the original image or snapshot the disk was created from. However, you can explicitly specify a hardware generation different from that assigned to the original image or snapshot.

To create a disk with the `Gen 2` hardware generation assigned:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the management console, select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) where you want to create an image.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![archive](../../../_assets/console-icons/archive.svg) **Disks and storages** and click **Create disk**. In the window that opens:

      1. Name the disk in the **Name** field. 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.
      1. In the **Availability zone** field, select an [availability zone](../../../overview/concepts/geo-scope.md) for the new disk.
      1. Depending on the source you are creating the disk from, in the **Contents** field, select `Snapshot` or `Image` and select the snapshot or image from the list that opens.
      1. In the **Type** field, select disk [type](../../concepts/disk.md#disks-types). Available values:

          * `SSD`: Fast network drive; SSD network block storage.
          * `HDD`: Standard network drive; HDD network block storage.
          * `SSD IO`: Enhanced performance network drive with redundancy.
          * `Non-replicated SSD`: Enhanced performance network drive without redundancy.
      1. In the **Size** field, specify the required disk size.
      1. Expand the **Additional** section and select `Gen 2 (GPT, UEFI)` in the **Hardware generation** field.
      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 Yandex Cloud CLI command to create a disk:

      ```bash
      yc compute disk create --help
      ```
  1. Create a disk with the `Gen 2` hardware generation assigned in the default folder:

      ```
      yc compute disk create \
        --name <disk_name> \
        --zone <availability_zone> \
        --type <disk_type> \
        --size <disk_size> \
        --source-image-id <source_image_ID> \
        --source-snapshot-id <source_snapshot_ID> \
        --hardware-generation-id generation2
      ```

      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.
      * `--type`: [Disk type](../../concepts/disk.md#disks-types). Available values:

          * `network-ssd`: Fast network drive; SSD network block storage.
          * `network-hdd`: Standard network drive; HDD network block storage.
          * `network-ssd-nonreplicated`: Enhanced performance network drive without redundancy.
          * `network-ssd-io-m3`: Enhanced performance network drive with redundancy.
      * `--size`: Disk size in GB. For example, specify `--size 32` to create a 32 GB disk.

      * Selecting a source for your disk:

          * `--source-image-id`: ID of the [image](../../concepts/image.md) you are creating the disk based on. Instead of the ID, you can provide its name in `--source-image-name`.
          * `--source-snapshot-id`: ID of the [snapshot](../../concepts/snapshot.md) you are creating the disk based on. Instead of the ID, you can provide its name in `--source-snapshot-name`.

          {% note info %}

          `--source-image-id`, `--source-image-name`, `--source-snapshot-id`, and `--source-snapshot-name` are mutually exclusive: you can use only one of them in the command.

          {% endnote %}

      Result:

      ```text
      done (9s)
      id: fv45fajiusvq********
      folder_id: b1gt6g8ht345********
      created_at: "2025-12-04T08:15:45Z"
      name: ubuntu2404-gen2-disk
      type_id: network-hdd
      zone_id: ru-central1-a
      size: "34359738368"
      block_size: "4096"
      product_ids:
        - f2ebiogvi127********
      status: READY
      source_image_id: fd8bnguet48k********
      disk_placement_policy: {}
      hardware_generation:
        generation2_features: {}
      ```

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

- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

  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>"
        type            = "<disk_type>"
        zone            = "<availability_zone>"
        size            = <disk_size>
        image_id        = "<source_image_ID>"
        snapshot_id     = "<source_snapshot_ID>"

        hardware_generation {
          generation2_features {}
        }
      }
      ```

      Where:
      * `name`: Name to assign to the disk. 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.

      * `type`: [Disk type](../../concepts/disk.md#disks-types). Available values:

          * `network-ssd`: Fast network drive; SSD network block storage.
          * `network-hdd`: Standard network drive; HDD network block storage.
          * `network-ssd-nonreplicated`: Enhanced performance network drive without redundancy.
          * `network-ssd-io-m3`: Enhanced performance network drive with redundancy.

      * `zone`: [Availability zone](../../../overview/concepts/geo-scope.md) of the new disk.
      * `size`: Disk size, in GB.
      * Selecting a source for your disk:

          * `image_id`: ID of the [image](../../concepts/image.md) you are creating the disk based on.
          * `snapshot_id`: ID of the [snapshot](../../concepts/snapshot.md) you are creating the disk based on.

          {% note info %}

          `image_id` and `snapshot_id` are mutually exclusive: you can use only one of them in the configuration file.

          {% endnote %}

          For more information about `yandex_compute_disk` properties, see [this Terraform provider guide](../../../terraform/resources/compute_disk.md).
          
  1. Create the resources:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.

      Terraform will create all the required resources. You can check new resources in the [management console](https://console.yandex.cloud) or using this CLI command:

      ```bash
      yc compute disk list
      ```

- API {#api}

  Use 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.

  For example, to create a disk with the `Gen 2` hardware generation assigned using REST API:

  1. Install [cURL](https://curl.haxx.se).
  1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) used for API authentication:
      * [Guide](../../../iam/operations/iam-token/create.md) for a Yandex account user
      * [Guide](../../../iam/operations/iam-token/create-for-sa.md) for a [service account](../../../iam/concepts/users/service-accounts.md)
      * [Guide](../../../iam/operations/iam-token/create-for-federation.md) for a federated account
      * [Guide](../../../iam/operations/iam-token/create-for-local.md) for a local account
  1. For your request to run smoothly, save the IAM token you got to the `IAM_TOKEN` environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token_contents>"
      ```
  1. Create a file containing the body of your disk create request (e.g., `body.json`), and add the following code to it:

      **body.json**

      ```json
      {
        "folderId": "<folder_ID>",
        "name": "<disk_name>",
        "typeId": "<disk_type>",
        "zoneId": "<availability_zone>",
        "size": "<disk_size_in_bytes>",
        "imageId": "<source_image_ID>",
        "snapshotId": "<source_snapshot_ID>",
        "hardwareGeneration": {
          "generation2Features": {}
        }
      }
      ```

      Where:

      * `folderId`: [ID](../../../resource-manager/operations/folder/get-id.md) of the disk folder.
      * `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.

      * `typeId`: [Disk type](../../concepts/disk.md#disks-types). Available values:

          * `network-ssd`: Fast network drive; SSD network block storage.
          * `network-hdd`: Standard network drive; HDD network block storage.
          * `network-ssd-nonreplicated`: Enhanced performance network drive without redundancy.
          * `network-ssd-io-m3`: Enhanced performance network drive with redundancy.

      * `zoneId`: [Availability zone](../../../overview/concepts/geo-scope.md) of the new disk.
      * `size`: Disk size, in bytes.
      * Selecting a source for your disk:

          * `imageId`: ID of the [image](../../concepts/image.md) you are creating the disk based on.
          * `snapshotId`: ID of the [snapshot](../../concepts/snapshot.md) you are creating the disk based on.

          {% note info %}

          The `imageId` and `snapshotId` fields are mutually exclusive, you can use only one of them in the request.

          {% endnote %}

  1. Run this http request:

      ```bash
      curl \
        --request POST \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer ${IAM_TOKEN}" \
        --data '@body.json' \
        https://compute.api.cloud.yandex.net/compute/v1/disks
      ```

      Result:

      ```text
      {
      "done": false,
      "metadata": {
        "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateDiskMetadata",
        "diskId": "fv4lmsdol4fi********"
      },
      "id": "fv4pt28gishg********",
      "description": "Create disk",
      "createdAt": "2025-12-04T09:19:00.743099068Z",
      "createdBy": "ajeol2afu1js********",
      "modifiedAt": "2025-12-04T09:19:00.743099068Z"
      }
      ```

{% endlist %}

This will create a disk with the `Gen 2` virtualized hardware [generation](../../concepts/hardware-generations.md) assigned.

## Create a VM running on Gen 2 hardware {#create-vm}

{% note info %}

Before you create a VM, [prepare](../vm-connect/ssh.md#creating-ssh-keys) a key pair (public and private) for SSH access to the VM.

{% endnote %}

Use a pre-prepared [image](#create-image), [snapshot](#create-snapshot), or [disk](#create-disk) with the `Gen 2` hardware generation assigned to create a VM based on that hardware generation:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) where you want to create your VM.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![server](../../../_assets/console-icons/server.svg) **Virtual machines** and click **Create virtual machine**.
  1. Under **Location**, select the [availability zone](../../../overview/concepts/geo-scope.md) where your VM will reside.

      {% note info %}

      If creating your VM by attaching a ready-made boot disk to it, make sure your disk is in the same availability zone you are creating your VM in.

      {% endnote %}

  1. Under **Boot disk image**, navigate to the **Custom** tab and click **Select**. In the window that opens:

      * To create a VM from a [pre-prepared snapshot](#create-snapshot):
      
          1. Make sure you selected `Create` at the top of the screen and `Snapshot` in the **Contents** field.
          1. Select the snapshot from the list. Optionally, use the filter.
          1. Name the VM boot disk in the **Name** field. 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.
          1. In the **Type** and **Size** fields, select the [type](../../concepts/disk.md#disks-types) and size for your new disk.
          1. Optionally, in the **Additional** field, enable **Delete along with the virtual machine** to activate auto-deletion of the new boot disk together with the VM.
          1. Click **Add disk**.
      * To create a VM from a [pre-prepared image](#create-image):
      
          1. Make sure you selected `Create` at the top of the screen.
          1. In the **Contents** field, select `Image`.
          1. Select the image from the list. Optionally, use the filter.
          1. Name the VM boot disk in the **Name** field. 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.
          1. In the **Type** and **Size** fields, select the [type](../../concepts/disk.md#disks-types) and size for your new disk.
          1. Optionally, in the **Additional** field, enable **Delete along with the virtual machine** to activate auto-deletion of the new boot disk together with the VM.
          1. Click **Add disk**.
      * To create a VM from a [pre-prepared disk](#create-disk):
      
          1. At the top of the screen, select `Attach existing`.
          1. Select the disk from the list. Optionally, use the filter.
          1. Optionally, in the **Additional** field, enable **Delete along with the virtual machine** to activate auto-deletion of the new boot disk together with the VM.
          1. Click **Add disk**.
  1. Under **Computing resources**, select one of the preset configurations or create a custom one. To create a custom configuration:
     
     * Go to the **Custom** tab.
     * Select a [platform](../../concepts/vm-platforms.md).
     * Specify the [guaranteed performance](../../concepts/performance-levels.md) and required number of vCPUs, as well as RAM size.
     * Enable a [software-accelerated network](../../concepts/software-accelerated-network.md) if needed.
     * Make your VM [preemptible](../../concepts/preemptible-vm.md), if required.
  1. Under **Network settings**:
     
     * In the **Subnet** field, enter the ID of a subnet in the new VM’s availability zone. Alternatively, select a [cloud network](../../../vpc/concepts/network.md#network) from the list.
     
         * Each network must have at least one [subnet](../../../vpc/concepts/network.md#subnet). If your network has no subnets, create one by selecting **Create subnet**.
         * If there are no networks in the list, click **Create network** to create one:
     
             * In the window that opens, specify the network name and select the folder where it will be created.
             * Optionally, enable the **Create subnets** setting to automatically create subnets in all availability zones.
             * Click **Create network**.
     
     * In the **Public IP address** field, select the IP address assignment method:
     
         * `Auto`: To assign a random IP address from the Yandex Cloud IP address pool. In this case, you can enable [DDoS protection](../../../vpc/ddos-protection/index.md) using the option below.
         * `List`: To select a public IP address from the list of previously reserved static addresses. For more information, see [Converting a dynamic public IP address to static](../../../vpc/operations/set-static-ip.md).
         * `No address`: Do not assign a public IP address.
     
     * Select [relevant security groups](../../../vpc/concepts/security-groups.md):
     
         * To connect to a virtual machine over `SSH`, the security group must allow incoming network traffic over `TCP` and `UDP` on port `22`.
     
         * To connect to a virtual machine over `RDP`, the security group must allow incoming network traffic over `TCP` and `UDP` on port `3389`.
         
         If you leave the field empty, the virtual machine will be automatically assigned the [default security group](../../../vpc/concepts/security-groups.md#default-security-group) allowing connections to the VM over `SSH` and `RDP`.
     
     * Expand **Additional** and select a method for assigning internal addresses in the **Internal IPv4 address** field:
     
         * `Auto`: To assign a random IP address from the pool of IP addresses available in the selected subnet.
         * `Manual`: To manually assign a private IP address to the VM.
         * Enable **DDoS protection**, if required. The option is available if you previously selected the automatic IP assignment method in the public address settings.
     
     * Optionally, create records for your VM in the [DNS zone](../../../dns/concepts/dns-zone.md):
     
         * Expand **DNS settings for internal addresses** and click **Add record**.
         * Specify a zone, FQDN, and TTL for the record. When setting the FQDN, you can enable `Detect automatically` for the zone.
           You can add multiple records to [internal DNS zones](../../../dns/concepts/dns-zone.md). For more information, see [Cloud DNS integration with Compute Cloud](../../../dns/concepts/compute-integration.md).
         * To create another record, click **Add record**.
     
     If you want to add another [network interface](../../concepts/network.md) to your VM, click **Add network interface** and repeat the settings from this step for the new interface. You can add up to eight network interfaces to a single VM.
  1. Under **Access**, select **SSH key** and specify the VM access credentials:
  
      * In the **Login** field, enter a username.
  
          {% note alert %}
  
          Do not use `root` or other reserved usernames. For operations requiring root privileges, use the `sudo` command.
  
          {% endnote %}
  
      * In the **SSH key** field, select the SSH key saved in your [organization user](../../../organization/concepts/membership.md) profile.
        
        If there are no SSH keys in your profile or you want to add a new key:
        
        1. Click **Add key**.
        1. Enter a name for the SSH key.
        1. Select one of the following:
        
            * `Enter manually`: Paste the contents of the public SSH key. You need to [create](../vm-connect/ssh.md#creating-ssh-keys) an SSH key pair on your own.
            * `Load from file`: Upload the public part of the SSH key. You need to create an SSH key pair on your own.
            * `Generate key`: Automatically create an SSH key pair.
            
              When adding a new SSH key, an archive containing the key pair will be created and downloaded. In Linux or macOS-based operating systems, unpack the archive to the `/home/<user_name>/.ssh` directory. In Windows, unpack the archive to the `C:\Users\<user_name>/.ssh` directory. You do not need additionally enter the public key in the management console.
        
        1. Click **Add**.
        
        The system will add the SSH key to your organization user profile. If the organization has [disabled](../../../organization/operations/os-login-access.md) the ability for users to add SSH keys to their profiles, the added public SSH key will only be saved in the user profile inside the newly created resource.

  1. Under **General information**, enter a name for your VM:

      * 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.

      {% note info %}
      
      The VM name is used to generate an [internal FQDN](../../concepts/network.md#hostname), which is set only once, when you create the VM. If the internal FQDN is important to you, make sure to choose an appropriate name for your VM.
      
      {% endnote %}

  1. Click **Create VM**.

- CLI {#cli}

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

     ```bash
     yc compute instance create --help
     ```
  1. Create a VM in the default [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder):

      ```bash
      yc compute instance create \
        --name <VM_name> \
        --zone <VM_availability_zone> \
        --network-interface subnet-id=<subnet_ID>,nat-ip-version=ipv4 \
        --create-boot-disk name=<disk_name>,type=<disk_type>,size=<disk_size>,image-id=<image_ID>,snapshot-id=<snapshot_ID>,auto-delete=true \
        --use-boot-disk disk-id=<ID_of_existing_disk>,auto-delete=true \
        --ssh-key "<path_to_public_SSH_key>"
      ```

      Where:
      * `--name`: VM 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.

          {% note info %}
          
          The VM name is used to generate an [internal FQDN](../../concepts/network.md#hostname), which is set only once, when you create the VM. If the internal FQDN is important to you, make sure to choose an appropriate name for your VM.
          
          {% endnote %}

      * `--zone`: [Availability zone](../../../overview/concepts/geo-scope.md) of the new VM.
      
          The VM availability zone must be the same as that of the subnet.
          
          When creating a VM using a pre-prepared boot disk, the VM availability zone must be the same as that of the boot disk.
      * `--network-interface`: VM [network interface](../../concepts/network.md) settings:
          * `subnet-id`: [Subnet](../../../vpc/concepts/network.md#subnet) ID.
          * `nat-ip-version=ipv4`: [Public IP address](../../../vpc/concepts/address.md#public-addresses). To create a VM without a public IP address, do not include this setting.

          If you want to add multiple [network interfaces](../../concepts/network.md) to your VM, specify the `--network-interface` parameter as many times as you need. You can add up to eight network interfaces to a single VM.

      * VM boot disk settings:

          {% note info %}

          `--create-boot-disk` and `--use-boot-disk` are mutually exclusive: you can use only one of them.

          {% endnote %}

          * `--create-boot-disk`: Enables creating a new boot disk for the VM, based on an image or snapshot, as follows:

              * `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.
              
              * `type`: Disk [type](../../concepts/disk.md#disks-types). Available values:

                  * `network-ssd`: Fast network drive; SSD network block storage.
                  * `network-hdd`: Standard network drive; HDD network block storage.
                  * `network-ssd-nonreplicated`: Enhanced performance network drive without redundancy.
                  * `network-ssd-io-m3`: Enhanced performance network drive with redundancy.
              * `size`: Disk size in GB.
              * Selecting a source to create your boot disk from:

                  * `image-id`: ID of the [pre-prepared image](#create-image) the VM boot disk will be created from.
                  * `snapshot-id`: ID of the [pre-prepared snapshot](#create-snapshot) the VM boot disk will be created from.

                      {% note info %}

                      The `image-id` and `snapshot-id` keys are mutually exclusive, you can use only one of them.

                      {% endnote %}

              * `auto-delete`: Auto-delete the boot disk together with the VM. See [Disk auto-deletion](../../concepts/disk.md#autodelete-disks).
          * `--use-boot-disk`: Allows using an existing [pre-prepared](#create-disk) boot disk for the VM:

              * `disk-id`: Existing boot disk ID.
              * `auto-delete`: Auto-delete the boot disk together with the VM. See [Disk auto-deletion](../../concepts/disk.md#autodelete-disks).
      * `--ssh-key`: Path to the file with the [public SSH key](../vm-connect/ssh.md#creating-ssh-keys). The VM will automatically create a user named `yc-user` for this key.

      Result:

      ```text
      done (19s)
      id: fv4l7qqpi4e0********
      folder_id: b1gt6g8ht345********
      created_at: "2025-12-05T18:23:55Z"
      name: my-first-gen2-vm
      zone_id: ru-central1-a
      platform_id: standard-v2
      resources:
        memory: "2147483648"
        cores: "2"
        core_fraction: "100"
      status: RUNNING
      metadata_options:
        gce_http_endpoint: ENABLED
        aws_v1_http_endpoint: ENABLED
        gce_http_token: ENABLED
        aws_v1_http_token: DISABLED
      boot_disk:
        mode: READ_WRITE
        device_name: fv4h89mv71cb********
        auto_delete: true
        disk_id: fv4h89mv71cb********
      network_interfaces:
        - index: "0"
          mac_address: d0:0d:15:3e:b5:99
          subnet_id: fl8dmq91iruu********
          primary_v4_address:
            address: 192.168.3.3
            one_to_one_nat:
              address: 158.160.***.***
              ip_version: IPV4
      serial_port_settings:
        ssh_authorization: OS_LOGIN
      gpu_settings: {}
      fqdn: fv4l7qqpi4e0********.auto.internal
      scheduling_policy: {}
      network_settings:
        type: STANDARD
      placement_policy: {}
      hardware_generation:
        generation2_features: {}
      application: {}
      ```

- Terraform {#tf}

  1. In the configuration file, describe the resources you want to create:

      ```hcl
      resource "yandex_compute_disk" "boot-disk" {
        name            = "<disk_name>"
        type            = "<disk_type>"
        zone            = "<availability_zone>"
        size            = "<disk_size>"
        image_id        = "<source_image_ID>"
        snapshot_id     = "<source_snapshot_ID>"
      }

      resource "yandex_compute_instance" "vm-1" {
        name                      = "<VM_name>"
        platform_id               = "standard-v3"
        zone                      = "<availability_zone>"

        resources {
          cores  = "<number_of_vCPUs>"
          memory = "<RAM_in_GB>"
        }

        boot_disk {
          auto_delete = true|false
          disk_id = yandex_compute_disk.boot-disk.id
        }

        network_interface {
          subnet_id = "<subnet_ID>"
          nat       = true
        }

        metadata = {
          ssh-keys = "<username>:<SSH_key_contents>"
        }
      }
      ```

      Where:
      * `yandex_compute_disk`: Boot [disk](../../concepts/disk.md) description:

          {% note info %}

          Use the `yandex_compute_disk` resource if creating a new boot disk for the VM from a pre-prepared image or snapshot.
          
          If your new VM is using an existing [pre-prepared](#create-disk) boot disk, specify the disk ID in the `boot_disk.disk_id` parameter of the `yandex_compute_instance` resource without creating a new `yandex_compute_disk` resource.

          {% endnote %}

          * `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.

          * `type`: Disk [type](../../concepts/disk.md#disks-types). Available values:

              * `network-ssd`: Fast network drive; SSD network block storage.
              * `network-hdd`: Standard network drive; HDD network block storage.
              * `network-ssd-nonreplicated`: Enhanced performance network drive without redundancy.
              * `network-ssd-io-m3`: Enhanced performance network drive with redundancy.
          * `zone`: [Availability zone](../../../overview/concepts/geo-scope.md) the disk will reside in.
          * `size`: Disk size, in GB.
          * Selecting a source for the boot disk:

              {% note info %}

              `image_id` and `snapshot_id` are mutually exclusive: you can use only one of them.

              {% endnote %}

              * `image_id`: ID of the [pre-prepared image](#create-image) the VM boot disk will be created from.
              * `snapshot_id`: ID of the [pre-prepared snapshot](#create-snapshot) the VM boot disk will be created from.

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

      * `yandex_compute_instance`: VM description:
          * `name`: VM 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.

          * `platform_id`: [Platform](../../concepts/vm-platforms.md).
          * `zone`: [Availability zone](../../../overview/concepts/geo-scope.md) the VM will reside in.

              The VM must reside in the same availability zone as the used subnet and also the VM boot disk if you are creating the VM from a previously prepared disk.
          * `resources`: Number of vCPUs and amount of RAM available to the VM. The values must match the selected [platform](../../concepts/vm-platforms.md).
          * `boot_disk`: Boot disk settings.
          
              * `disk_id`: Disk ID. If your new VM is intended to be using an existing boot disk [you prepared earlier](#create-disk), specify the disk ID in this parameter.
              * `auto_delete`: Auto-delete the boot disk together with the VM. See [Disk auto-deletion](../../concepts/disk.md#autodelete-disks).
          * `network_interface`: VM [network interface](../../concepts/network.md) settings:
          
              * `subnet_id`: ID of the [subnet](../../../vpc/concepts/network.md#subnet) in the same availability zone as the new VM.
              * To automatically assign a [public IP address](../../../vpc/concepts/address.md#public-addresses) to the VM, set `nat = true`.

              If you want to add multiple [network interfaces](../../concepts/network.md) to your VM, specify the `network_interface` section as many times as you need.

          * `metadata`: In the metadata, provide the user name and public SSH key for VM access. For more information, see [VM metadata](../../concepts/vm-metadata.md).

      For more information about `yandex_compute_instance` properties, see [this Terraform provider guide](../../../terraform/resources/compute_instance.md).
          
  1. Create the resources:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.

      Terraform will create all the required resources. You can check new resources in the [management console](https://console.yandex.cloud) or using this CLI command:

      ```bash
      yc compute instance list
      ```

- API {#api}

  Use the [create](../../api-ref/Instance/create.md) REST API method for the [Instance](../../api-ref/Instance/index.md) resource or the [InstanceService/Create](../../api-ref/grpc/Instance/create.md) gRPC API call.

  For example, to create a VM using REST API:

  1. Install [cURL](https://curl.haxx.se).
  1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) used for API authentication:
      * [Guide](../../../iam/operations/iam-token/create.md) for a Yandex account user
      * [Guide](../../../iam/operations/iam-token/create-for-sa.md) for a [service account](../../../iam/concepts/users/service-accounts.md)
      * [Guide](../../../iam/operations/iam-token/create-for-federation.md) for a federated account
      * [Guide](../../../iam/operations/iam-token/create-for-local.md) for a local account
  1. For your request to run smoothly, save the IAM token you got to the `IAM_TOKEN` environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token_contents>"
      ```
  1. Create a file containing the body of your VM create request (e.g., `body.json`), and add the following code to it:

      **body.json**

      ```json
      {
        "folderId": "<folder_ID>",
        "name": "<VM_name>",
        "zoneId": "<availability_zone>",
        "platformId": "standard-v3",
        "resourcesSpec": {
          "memory": "<RAM_in_bytes>",
          "cores": "<number_of_vCPUs>"
        },
        "metadata": {
          "user-data": "#cloud-config\nusers:\n  - name: user\n    groups: sudo\n    shell: /bin/bash\n    sudo: 'ALL=(ALL) NOPASSWD:ALL'\n    ssh_authorized_keys:\n      - ssh-ed25519 AAAAB3N... user@example.com"
        },
        "bootDiskSpec": {
          "autoDelete": true,
          "diskSpec": {
            "size": "<disk_size_in_bytes>",
            "imageId": "<source_image_ID>",
            "snapshotId": "<source_snapshot_ID>"
          },
          "diskId": "<disk_ID>"
        },
        "networkInterfaceSpecs": [
          {
            "subnetId": "<subnet_ID>",
            "primaryV4AddressSpec": {
              "oneToOneNatSpec": {
                "ipVersion": "IPV4"
              }
            }
          }
        ]
      }
      ```

      Where:

      * `folderId`: [ID](../../../resource-manager/operations/folder/get-id.md) of the VM folder.
      * `name`: VM 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.

      * `zoneId`: [Availability zone](../../../overview/concepts/geo-scope.md) the VM will reside in.

          The VM must reside in the same availability zone as the used subnet and also the VM boot disk if you are creating the VM from a [previously prepared disk](#create-disk).
      * `platformId`: VM [platform](../../concepts/vm-platforms.md).
      * `resourceSpec`: Number of vCPUs and amount of RAM available to the VM. The values must match the selected [platform](../../concepts/vm-platforms.md).
      * `metadata`: In metadata, provide the public key for accessing the VM via SSH. For more information, see [VM metadata](../../concepts/vm-metadata.md).
      * `bootDiskSpec`: VM boot disk settings:

          * `autoDelete`: Auto-delete the boot disk together with the VM. See [Disk auto-deletion](../../concepts/disk.md#autodelete-disks).

          {% note info %}

          `diskSpec` and `diskId` are mutually exclusive: you can use only one of them.

          {% endnote %}

          * `diskSpec`: Settings for your new boot disk if created from a previously prepared image or snapshot:

              * `size`: New disk size, in bytes.
              * Selecting a source to create your boot disk from:

                  {% note info %}

                  `imageId` and `snapshotId` are mutually exclusive: you can use only one of them.

                  {% endnote %}

                  * `imageId`: ID of the [previously prepared image](#create-image) the VM boot disk will be created from.
                  * `snapshotId`: ID of the [previously prepared snapshot](#create-snapshot) the VM boot disk will be created from.
          * `diskId`: ID of an existing boot disk [you prepared earlier](#create-disk) if it is used to create a VM.
      * `networkInterfaceSpecs`: VM [network interface](../../concepts/network.md) settings:

          * `subnetId`: ID of the selected [subnet](../../../vpc/concepts/network.md#subnet). The subnet must be in the same availability zone as your new VM.
          * `primaryV4AddressSpec`: IP address to assign to the VM. To add a [public IP address](../../../vpc/concepts/address.md#public-addresses) to your VM, specify the following:

            ```json
            "primaryV4AddressSpec": {
              "oneToOneNatSpec": {
                "ipVersion": "IPV4"
              }
            }
            ```
          To add multiple [network interfaces](../../concepts/network.md) to your VM, provide an array with the required number of objects containing network interface settings in the `networkInterfaceSpecs` parameter.

  1. Run this http request:

      ```bash
      curl \
        --request POST \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer ${IAM_TOKEN}" \
        --data '@body.json' \
        https://compute.api.cloud.yandex.net/compute/v1/instances
      ```

      Result:

      ```text
      {
      "done": false,
      "metadata": {
        "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateInstanceMetadata",
        "instanceId": "fv41kcr9qbd8********"
      },
      "id": "fv4tll89q78c********",
      "description": "Create instance",
      "createdAt": "2025-12-05T20:37:44.940310692Z",
      "createdBy": "ajeol2afu1jsk********",
      "modifiedAt": "2025-12-05T20:37:44.940310692Z"
      }
      ```

{% endlist %}

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

* [Hardware generations](../../concepts/hardware-generations.md)