Creating an image from a disk
To create an image from a disk:
Note
You can use the management console to create images of network SSDs and HDDs. To create an image of a non-replicated SSD or an ultra high-speed network storage with three replicas (SSD), use the CLI, Terraform, or API.
-
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. -
In the line with the disk, click
and select Create image. -
Specify the 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.
-
Provide a text description for the image, if required.
-
Expand the Additional section:
-
Optionally, in the Hardware generation field, select the desired generation of virtualized hardware to be assigned to the created image:
Gen 1.2 (MBR, BIOS):Gen 1.2.Gen 1.1 (MBR, BIOS):Gen 1.1.
If you make no assignment, by default new image will get the same generation assigned as the source disk.
-
Optionally, to create an optimized image, enable Optimization.
-
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.
-
See the description of the CLI command for creating an image:
yc compute image create --help -
Get a list of disks in the default folder:
yc compute disk listResult:
+----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | ID | NAME | SIZE | ZONE | STATUS | INSTANCE IDS | PLACEMENT GROUP | DESCRIPTION | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | a7lqgbt0bb9s******** | first-disk | 20401094656 | ru-central1-a | READY | a7lcvu28njbh******** | | | | a7lv5j5hm1p1******** | second-disk | 21474836480 | ru-central1-a | READY | | | | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ -
Select
IDorNAMEof the disk you need. -
Create an image in the default folder:
yc compute image create \ --name <name_of_new_image> \ --source-disk-name <source_disk_name> \ --pooled \ --hardware-generation-id <hardware_generation> \ --hardware-features pci_topology=<PCI_topology>Where:
-
--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.
-
--source-disk-name: Source disk name. Instead of name, you can provide the source disk ID in the--source-disk-idparameter. -
--pooled: This parameter allows creating an optimized image. This is an optional setting. -
--hardware-generation-id: Virtualized hardware generation assigned to the image. This is an optional setting. The possible values are:legacy:Gen 1. If you select this generation, you can also specify the PCI topology in the--hardware-featuresparameter.
If not specified, the created image will get the same hardware generation assigned as the source disk.
-
--hardware-features: Additional settings forGen 1. This is an optional setting. The possible values are:pci_topology=v1:PCI_TOPOLOGY_V1topology.pci_topology=v2: Adopts thePCI_TOPOLOGY_V2topology.
If the source disk has
Gen 1assigned, by default the new image will get the same--hardware-featuresvalue as the source disk.
Result:
done (33s) id: fd8ar40hlfbk******** folder_id: b1gt6g8ht345******** created_at: "2025-06-23T18:53:39Z" name: my-first-image storage_size: "3116367872" min_disk_size: "21474836480" product_ids: - f2evcrm9ti79******** status: READY os: type: LINUX hardware_generation: legacy_features: pci_topology: PCI_TOPOLOGY_V1 -
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_disk = "<source_disk_ID>" hardware_generation { legacy_features { pci_topology = "<PCI_topology>" } } }Where:
-
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.
-
source_disk: Source disk ID. -
hardware_generation: Block of settings describing the virtualized hardware generation assigned to the image. This is an optional setting. It includes the following blocks of settings:-
legacy_features: Settings with the description of parameters forGen 1:-
pci_topology: Selecting the PCI topology. The possible values are:PCI_TOPOLOGY_V1PCI_TOPOLOGY_V2
The
legacy_featuresandgeneration2_featuressections are mutually exclusive. -
Note
If the
hardware_generationsettings are not specified, the created image will get the same hardware generation assigned as the source disk. -
For more information about the
yandex_compute_imageresource, see the relevant provider documentation. -
-
Make sure the configuration files are correct.
-
In the command line, navigate to the directory where you created the configuration file.
-
Run a check using this command:
terraform plan
If the configuration description is correct, the terminal will display a list of the resources being created and their settings. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy the cloud resources.
-
Run this command:
terraform apply -
Confirm creating the resources.
This will create all the resources you need in the specified folder. You can check the new resources and their settings using the management console
. -
- Get a list of disks using the list REST API method for the Disk resource or the DiskService/List gRPC API call.
- Create an image using the create REST API method for the Image resource or the ImageService/Create gRPC API call. In your request, specify the source disk ID, and optionally the desired virtualized hardware generation in the
hardwareGenerationobject (hardware_generationif using the gRPC API).
Once created, the image will get the CREATING status. Wait until its status changes to READY before using it.