Creating a VM with Gen 2 hardware
The VM runs on virtualized hardware of the generation assigned to the medium (i.e., image, snapshot, or disk) 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 from this medium.
To create a VM running on virtualized Gen 2 hardware, proceed as follows:
- Prepare a medium of one of these types: image, snapshot, or disk.
- Create a VM from the medium you prepared.
Create an image with the Gen 2 hardware generation assigned
You can create a VM image with the Gen 2 hardware generation assigned either from your own image pre-uploaded to Yandex Cloud or from existing images, snapshots, and disks available in Yandex Cloud.
Upload your disk image to Yandex Cloud
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.
Prepare an image file
Make sure the following requirements for boot disk images are met:
- The
virtio-net,virtio-blk, andvirtio-pcidrivers are installed. If you are going to attach file storages to your VM, you also need to install thevirtiofsdriver. For details, see this guide. - The
ttyS0terminal (COM1) is configured as the serial console. For details, see this guide. - The network interface runs correctly when starting the VM and gets the IP address via DHCP.
- The
cloud-initpackage is installed and configured to work with our metadata service. Runsudo yum install cloud-initto install the package for CentOS orsudo apt update && sudo apt install -y cloud-initto 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-initsettings. For details, see this guide. - 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.
- The boot disk uses MBR partitioning.
- 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 configuration steps, see Setting up a custom disk image.
Upload the image file to Object Storage
Upload your image file to Object Storage and get a shareable link:
- If you have no Object Storage bucket yet, create one with restricted access.
- Upload your image to the bucket via the management console, AWS CLI, or WinSCP. In Object Storage terminology, your uploaded image will be called an object.
- Get a signed link 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
To create a new image using the link you got in Object Storage:
-
In the management console, select the folder where you want to create the image.
-
Go to Compute Cloud.
-
In the left-hand panel, select
Images. -
Click Upload image, and in the window that opens:
-
In the Name field, enter a name for the image. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Optionally, in the Description and Labels fields, add a description and labels for the new image.
-
In the Link to image in Object Storage field, paste the image file link you got in Object Storage earlier.
-
In the Hardware generation field, select the
Gen 2 (GPT, UEFI)hardware generation. -
To enable image optimization for deployment, expand Additional and enable the Optimization option.
-
Click Upload.
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
See the description of the Yandex Cloud CLI command for creating an image:
yc compute image create --help -
To create a new image with the
Gen 2hardware generation assigned using a link, run this command:yc compute image create \ --name <image_name> \ --source-uri "<image_URL>" \ --hardware-generation-id generation2 \ --pooledWhere:
-
--name: Name to assign to the image. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 for deployment. This is an optional setting. By default, the optimization is disabled.
Result:
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.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To create an image:
-
Specify the parameters of the
yandex_compute_imageresource in the configuration file.Here is an example of the configuration file structure:
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. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 for deployment. The possible values are:true: Optimization enabled.false: Optimization disabled.
This is an optional setting. By default, the optimization is disabled.
For detailed information about the
yandex_compute_imageresource parameters, see this Terraform provider guide. -
-
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check new resources in the management console
or using this CLI command:yc compute image list -
Use the create REST API method for the Image resource or the ImageService/Create gRPC API call.
For example, to create an image with the Gen 2 hardware generation assigned using REST API:
-
Install cURL
. -
Get an IAM token used for API authentication:
- Guide for a Yandex account user
- Guide for a service account
- Guide for a federated account
- Guide for a local account
-
For your request to run smoothly, save the IAM token you got to the
IAM_TOKENenvironment variable:export IAM_TOKEN="<IAM_token_contents>" -
Create a file containing the body of your image create request (e.g.,
body.json) and add the following code to it:body.json
{ "folderId": "<folder_ID>", "name": "<image_name>", "uri": "<link_to_uploaded_image>", "pooled": "true|false", "hardwareGeneration": { "generation2Features": {} } }Where:
-
folderId: ID of the image folder. -
name: Image name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 for deployment. The possible values are:true: Optimization enabled.false: Optimization disabled.
This is an optional setting. By default, the optimization is disabled.
-
-
Run this http request:
curl \ --request POST \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --data '@body.json' \ https://compute.api.cloud.yandex.net/compute/v1/imagesResult:
{ "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" }
After you create the image, you can delete the original file from the bucket.
Creating a disk image with the Gen 2 hardware generation assigned from another image, snapshot, or disk
By default, a newly created image is assigned the hardware generation assigned 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 available for installation on VMs in Yandex Cloud 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) support Gen 2 hardware with UEFIGen 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
You can create a new image with the Gen 2 hardware generation assigned from a public image in Yandex Cloud Marketplace only with the help the Yandex Cloud CLI, Terraform, or API.
To create an image from an existing image, snapshot, or disk:
-
In the management console, select the folder where you want to create an image.
-
Go to Compute Cloud.
-
Depending on the source you want to create the new image from, select
Disks and storages, Snapshots, or Images in the left-hand panel. -
Depending on the source type you selected, in the list that opens, click
next to the image, snapshot, or disk, and select Create image. In the window that opens:-
In the Name field, enter a name for the new image. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Optionally, in the Description and Labels fields, add a description and labels for the new image.
-
Expand the Additional section and select
Gen 2 (GPT, UEFI)in the Hardware generation field. -
To enable image optimization for deployment, enable the Optimization option.
-
Click Create.
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
Alert
-
See the description of the Yandex Cloud CLI command for creating an image:
yc compute image create --help -
To create a new image with the
Gen 2hardware generation assigned from an existing image, snapshot, or disk, run this command: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 \ --pooledWhere:
-
--name: Name to assign to the image. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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
--source-image-id,--source-image-name,--source-snapshot-id,--source-snapshot-name,--source-disk-id, and--source-disk-nameare mutually exclusive: you can use only one of them in the command. -
--pooled: Enables image optimization for deployment. This is an optional setting. By default, the optimization is disabled.
Result:
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.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Define the parameters of the
yandex_compute_imageresource in the configuration file.Here is an example of the configuration file structure:
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 {} } }Alert
Where:
-
name: Name to assign to the image. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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
source_image,source_snapshot, andsource_diskare mutually exclusive: you can use only one of them in the configuration file. -
pooled: Enables image optimization for deployment. The possible values are:true: Optimization enabled.false: Optimization disabled.
This is an optional setting. By default, the optimization is disabled.
For detailed information about the
yandex_compute_imageresource parameters, see this Terraform provider guide.
-
-
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check new resources in the management console
or using this CLI command:yc compute image list -
Use the create REST API method for the Image resource or the ImageService/Create gRPC API call.
For example, to create an image with the Gen 2 hardware generation assigned using REST API:
-
Install cURL
. -
Get an IAM token used for API authentication:
- Guide for a Yandex account user
- Guide for a service account
- Guide for a federated account
- Guide for a local account
-
For your request to run smoothly, save the IAM token you got to the
IAM_TOKENenvironment variable:export IAM_TOKEN="<IAM_token_contents>" -
Create a file containing the body of your image create request (e.g.,
body.json) and add the following code to it:body.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 of the image folder. -
name: Image name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
Alert
-
Selecting a source for your image:
imageId: Source image ID.snapshotId: Source snapshot ID.diskId: Source disk ID.
Note
The
imageId,snapshotId, anddiskIdfields are mutually exclusive: you can use only one of them in the request. -
pooled: Enables image optimization for deployment. The possible values are:true: Optimization enabled.false: Optimization disabled.
This is an optional setting. By default, the optimization is disabled.
-
-
Run this http request:
curl \ --request POST \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --data '@body.json' \ https://compute.api.cloud.yandex.net/compute/v1/imagesResult:
{ "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" }
This will create an image with the Gen 2 virtualized hardware generation assigned.
Create a disk snapshot with the Gen 2 hardware generation assigned
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
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:
-
Stop all disk write operations in applications.
-
Write the OS cache to the disk:
sync -
Freeze the file system:
sudo fsfreeze --freeze <mount_point>Where
--freezeis the parameter to freeze the file system. Replace<mount_point>with the folder where the file system is mounted, e.g.,/mnt/vdc2. -
Create a snapshot by following the steps below.
-
Unfreeze the file system:
sudo fsfreeze --unfreeze <mount_point>Where
--unfreezeis the parameter to unfreeze the file system. Replace<mount_point>with the folder where the file system is mounted, e.g.,/mnt/vdc2.
- Stop the VM (see Stopping).
- Wait until the VM status changes to
STOPPED.
Create a snapshot
To create a disk snapshot with the Gen 2 hardware generation assigned:
Note
You can assign to a snapshot a generation different from the one assigned to the source disk only using the Yandex Cloud CLI, Terraform, or API.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
See the description of the CLI command for creating snapshots:
yc compute snapshot create --help -
Create a snapshot in the default folder:
yc compute snapshot create \ --name <snapshot_name> \ --disk-id <source_disk_ID> \ --hardware-generation-id generation2Where:
-
--name: Snapshot name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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:
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.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Define the parameters of the
yandex_compute_snapshotresource in the configuration file.Here is an example of the configuration file structure:
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. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 to create the snapshot for.
For detailed information about the
yandex_compute_snapshotresource parameters, see this Terraform provider guide. -
-
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check new resources in the management console
or using this CLI command:yc compute snapshot list -
Use the create REST API method for the Snapshot resource or the SnapshotService/Create gRPC API call.
For example, to create a snapshot with the Gen 2 hardware generation assigned using REST API:
-
Install cURL
. -
Get an IAM token used for API authentication:
- Guide for a Yandex account user
- Guide for a service account
- Guide for a federated account
- Guide for a local account
-
For your request to run smoothly, save the IAM token you got to the
IAM_TOKENenvironment variable:export IAM_TOKEN="<IAM_token_contents>" -
Create a file containing the body of your snapshot create request (e.g.,
body.json), and add the following code to it:body.json
{ "folderId": "<folder_ID>", "name": "<snapshot_name>", "diskId": "<disk_ID>", "hardwareGeneration": { "generation2Features": {} } }Where:
-
folderId: ID of the snapshot folder. -
name: Snapshot name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 you are making a snapshot of.
-
-
Run this http request:
curl \ --request POST \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --data '@body.json' \ https://compute.api.cloud.yandex.net/compute/v1/snapshotsResult:
{ "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" }
This will create a disk snapshot with the Gen 2 virtualized hardware generation assigned.
Create a disk with the Gen 2 hardware generation assigned
By default, a newly created disk is assigned the hardware generation assigned 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:
-
In the management console, select the folder where you want to create an image.
-
Go to Compute Cloud.
-
In the left-hand panel, select
Disks and storages and click Create disk. In the window that opens:-
Name the disk in the Name field. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
In the Availability zone field, select an availability zone for the new disk.
-
Depending on the source you are creating the disk from, in the Contents field, select
SnapshotorImageand select the snapshot or image from the list that opens. -
In the Type field, select disk type. Possible 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.
-
In the Size field, specify the required disk size.
-
Expand the Additional section and select
Gen 2 (GPT, UEFI)in the Hardware generation field. -
Click Create disk.
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
View the description of the Yandex Cloud CLI command to create a disk:
yc compute disk create --help -
Create a disk with the
Gen 2hardware 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 generation2Where:
-
--name: Disk name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 of the new disk. -
--type: Disk type. Possible 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 32to create a 32 GB disk. -
Selecting a source for your disk:
--source-image-id: ID of the image 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 you are creating the disk based on. Instead of the ID, you can provide its name in--source-snapshot-name.
Note
--source-image-id,--source-image-name,--source-snapshot-id, and--source-snapshot-nameare mutually exclusive: you can use only one of them in the command.
Result:
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.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Define the parameters of the
yandex_compute_diskresource in the configuration file.Here is a configuration file example:
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. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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. Possible 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 of the new disk. -
size: Disk size in GB. -
Selecting a source for your disk:
image_id: ID of the image you are creating the disk based on.snapshot_id: ID of the snapshot you are creating the disk based on.
Note
image_idandsnapshot_idare mutually exclusive: you can use only one of them in the configuration file.For detailed information about the
yandex_compute_diskresource parameters, see this Terraform provider guide.
-
-
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check new resources in the management console
or using this CLI command:yc compute disk list -
Use the create REST API method for the Disk resource or the DiskService/Create gRPC API call.
For example, to create a disk with the Gen 2 hardware generation assigned using REST API:
-
Install cURL
. -
Get an IAM token used for API authentication:
- Guide for a Yandex account user
- Guide for a service account
- Guide for a federated account
- Guide for a local account
-
For your request to run smoothly, save the IAM token you got to the
IAM_TOKENenvironment variable:export IAM_TOKEN="<IAM_token_contents>" -
Create a file containing the body of your disk create request (e.g.,
body.json), and add the following code to it:body.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 of the disk folder. -
name: Disk name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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. Possible 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 of the new disk. -
size: Disk size, in bytes. -
Selecting a source for your disk:
imageId: ID of the image you are creating the disk based on.snapshotId: ID of the snapshot you are creating the disk based on.
Note
The
imageIdandsnapshotIdfields are mutually exclusive, you can use only one of them in the request.
-
-
Run this http request:
curl \ --request POST \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --data '@body.json' \ https://compute.api.cloud.yandex.net/compute/v1/disksResult:
{ "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" }
This will create a disk with the Gen 2 virtualized hardware generation assigned.
Create a VM running on Gen 2 hardware
Note
Before you create a VM, prepare a key pair (public and private) for SSH access to the VM.
Use a pre-prepared image, snapshot, or disk with the Gen 2 hardware generation assigned to create a VM based on that hardware generation:
-
In the management console
, select the folder where you want to create your VM. -
Go to Compute Cloud.
-
In the left-hand panel, select
Virtual machines and click Create virtual machine. -
Under Location, select the availability zone where your VM will reside.
Note
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.
-
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:
-
Make sure you selected
Createat the top of the screen andSnapshotin the Contents field. -
Select the snapshot from the list. Optionally, use the filter.
-
Name the VM boot disk in the Name field. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
In the Type and Size fields, select the type and size for your new disk.
-
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.
-
Click Add disk.
-
-
To create a VM from a pre-prepared image:
-
Make sure you selected
Createat the top of the screen. -
In the Contents field, select
Image. -
Select the image from the list. Optionally, use the filter.
-
Name the VM boot disk in the Name field. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
In the Type and Size fields, select the type and size for your new disk.
-
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.
-
Click Add disk.
-
-
To create a VM from a pre-prepared disk:
- At the top of the screen, select
Attach existing. - Select the disk from the list. Optionally, use the filter.
- 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.
- Click Add disk.
- At the top of the screen, select
-
-
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.
- Specify the guaranteed performance and required number of vCPUs, as well as RAM size.
- Optionally, enable a software-accelerated network.
- Make your VM preemptible, if required.
-
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 from the list.
-
Each network must have at least one subnet. If your network has no subnets, create one by selecting Create subnet.
-
If you do not have a network, click Create network to create one:
- In the window that opens, specify the network name and select the folder to host the network.
- Optionally, enable the Create subnets setting to automatically create subnets in all availability zones.
- Click Create network.
-
-
In the Public IP address field, select an 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 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.No address: Not to assign a public IP address.
-
Select the relevant security groups. If you leave this field empty, the default security group will be assigned to the VM.
-
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:
- 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 automaticallyfor the zone.
You can add multiple records to internal DNS zones. For more information, see Cloud DNS integration with Compute Cloud. - To create another record, click Add record.
If you want to add another network interface 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.
-
-
Under Access, select SSH key and specify the VM access credentials:
-
In the Login field, enter the username.
Alert
Do not use
rootor other reserved usernames. For operations requiring root privileges, use thesudocommand. -
In the SSH key field, select the SSH key saved in your organization user profile.
If there are no SSH keys in your profile or you want to add a new key:
-
Click Add key.
-
Enter a name for the SSH key.
-
Select one of the following:
-
Enter manually: Paste the contents of the public SSH key. You need to create 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>/.sshdirectory. In Windows, unpack the archive to theC:\Users\<user_name>/.sshdirectory. You do not need additionally enter the public key in the management console.
-
-
Click Add.
The system will add the SSH key to your organization user profile. If the organization has disabled 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.
-
-
-
Under General information, enter a name for your VM:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
Note
The VM name is used to generate an internal FQDN, 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.
-
Click Create VM.
-
View the description of the CLI command to create a VM:
yc compute instance create --help -
Create a VM in the default folder:
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. Follow these naming requirements:- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
Note
The VM name is used to generate an internal FQDN, 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.
-
--zone: Availability zone 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 settings:subnet-id: Subnet ID.nat-ip-version=ipv4: Public IP address. To create a VM without a public IP address, omit this parameter.
If you want to add multiple network interfaces to your VM, specify the
--network-interfaceparameter as many times as you need. You can add up to eight network interfaces to a single VM. -
VM boot disk settings:
Note
--create-boot-diskand--use-boot-diskare mutually exclusive: you can use only one of them.-
--create-boot-disk: Enables creating a new boot disk for the VM based on an image or snapshot:-
name: Disk name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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. Possible 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 for the boot disk:
-
image-id: ID of the pre-prepared image the VM boot disk will be created from. -
snapshot-id: ID of the pre-prepared snapshot the VM boot disk will be created from.Note
The
image-idandsnapshot-idkeys are mutually exclusive, you can use only one of them.
-
-
auto-delete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.
-
-
--use-boot-disk: Allows using an existing pre-prepared 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.
-
-
--ssh-key: Path to the file with the public SSH key. The VM will automatically create a user namedyc-userfor this key.
Result:
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: {} -
-
In the configuration file, describe the resources you want to create:
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 description:Note
Use the
yandex_compute_diskresource if creating a new boot disk for the VM from a pre-prepared image or snapshot.If your new VM will use an existing pre-prepared boot disk, specify the disk's ID in the
boot_disk.disk_idparameter of theyandex_compute_instanceresource without creating a newyandex_compute_diskresource.-
name: Disk name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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. Possible 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 the disk will reside in. -
size: Disk size in GB. -
Selecting a source for the boot disk:
Note
image_idandsnapshot_idare mutually exclusive: you can use only one of them.image_id: ID of the pre-prepared image the VM boot disk will be created from.snapshot_id: ID of the pre-prepared snapshot the VM boot disk will be created from.
For detailed information about the
yandex_compute_diskresource parameters, see this Terraform provider guide. -
-
yandex_compute_instance: VM description:-
name: VM name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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. -
zone: Availability zone the VM will reside in.The VM must reside in the same availability zone as the subnet, plus in the same availability zone as the boot disk if created from a pre-prepared disk.
-
resources: Number of vCPUs and amount of RAM available to the VM. The values must match the selected platform. -
boot_disk: Boot disk settings.disk_id: Disk ID. If your new VM will use an existing pre-prepared boot disk, specify its ID in this parameter.auto_delete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.
-
network_interface: VM network interface settings:subnet_id: ID of the subnet in the same availability zone as the new VM.- To automatically assign a public IP address to the VM, set
nat = true.
If you want to add multiple network interfaces to your VM, specify the
network_interfacesection 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.
-
For detailed information about the
yandex_compute_instanceresource parameters, see this Terraform provider guide. -
-
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check new resources in the management console
or using this CLI command:yc compute instance list -
Use the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.
For example, to create a VM using REST API:
-
Install cURL
. -
Get an IAM token used for API authentication:
- Guide for a Yandex account user
- Guide for a service account
- Guide for a federated account
- Guide for a local account
-
For your request to run smoothly, save the IAM token you got to the
IAM_TOKENenvironment variable:export IAM_TOKEN="<IAM_token_contents>" -
Create a file containing the body of your VM create request (e.g.,
body.json), and add the following code to it:body.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 of the VM folder. -
name: VM name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 the VM will reside in.The VM must reside in the same availability zone as the subnet, plus in the same availability zone as the boot disk if created from a pre-prepared disk.
-
platformId: VM platform. -
resourceSpec: Number of vCPUs and amount of RAM available to the VM. The values must match the selected platform. -
metadata: In metadata, provide the public key for accessing the VM via SSH. For more information, see VM metadata. -
bootDiskSpec: VM boot disk settings:autoDelete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.
Note
diskSpecanddiskIdare mutually exclusive: you can use only one of them.-
diskSpec: Setting of the new boot disk if created from a pre-prepared image or snapshot:-
size: New disk size, in bytes. -
Selecting a source for the boot disk:
Note
imageIdandsnapshotIdare mutually exclusive: you can use only one of them.imageId: ID of the pre-prepared image the VM boot disk will be created from.snapshotId: ID of the pre-prepared snapshot the VM boot disk will be created from.
-
-
diskId: ID of the existing pre-prepared boot disk if one is used to create the VM.
-
networkInterfaceSpecs: VM network interface settings:-
subnetId: ID of the selected 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 to your VM, specify the following:"primaryV4AddressSpec": { "oneToOneNatSpec": { "ipVersion": "IPV4" } }
To add multiple network interfaces to your VM, provide an array with the required number of objects containing network interface settings in the
networkInterfaceSpecsparameter. -
-
-
Run this http request:
curl \ --request POST \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --data '@body.json' \ https://compute.api.cloud.yandex.net/compute/v1/instancesResult:
{ "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" }