Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Compute Cloud
    • All guides
      • Stopping and starting a VM
      • Resetting a Windows Server VM user password
      • Attaching a disk to a VM
      • Detaching a disk from a VM
      • Moving a VM to a different availability zone
      • Moving a VM to a different folder
      • Moving a VM to a different cloud
      • Adding another network interface to a VM
      • Deleting a network interface from a VM
      • Assigning a public IP address to a VM
      • Unassigning a public IP address from a VM
      • Making a VM public IP address static
      • Reassigning a public IP address from one VM to another
      • Updating the VM internal IP address
      • Updating a VM
      • Changing VM computing resources
      • Changing VM security groups
      • VM maintenance policy management
      • Configuring VM access permissions
      • Linking a service account to a VM
      • Deleting a VM
    • Viewing operations with resources
  • Yandex Container Solution
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Moving a VM using disk snapshots
  • Create a snapshot of each of the VM disks
  • Create a VM in a different availability zone with the disks from the snapshots
  • Delete the source VM
  • Moving a VM using a special command
  • Examples
  1. Step-by-step guides
  2. Managing a VM
  3. Moving a VM to a different availability zone

Moving a VM to a different availability zone

Written by
Yandex Cloud
Improved by
Danila N.
Updated at May 5, 2025
  • Moving a VM using disk snapshots
    • Create a snapshot of each of the VM disks
    • Create a VM in a different availability zone with the disks from the snapshots
    • Delete the source VM
  • Moving a VM using a special command
    • Examples

When creating a VM, you can select a Yandex Cloud availability zone to place it in.

You can move an existing VM to a different availability zone using a special command in the management console or the CLI, or by creating its copy in the target availability zone using disk snapshots.

Warning

To monitor the migration progress and avoid potential issues, use disk snapshots or backups from Cloud Backup. This way, you can decide when to shut down your VM in the source availability zone and when to make it appear in the target availability zone. You can keep the VM in the source availability zone running until you make sure the VM you created from the snapshot in the new zone works correctly. You can read more about the relevant best practices in Migrating resources to a different availability zone.

Currently, you can use the relocate command to migrate VMs and disks only to the ru-central1-d zone from any other zone.

Warning

The ru-central1-d zone does not support VMs based on the Intel Broadwell platform. To move such VMs to the ru-central1-d zone, do one of the following:

  • Take a disk snapshot and use it to create a new VM in the ru-central1-d zone on a different platform.
  • Stop the VM, change the platform, and move the VM by running relocate.

Moving a VM using disk snapshotsMoving a VM using disk snapshots

To move a VM to a different availability zone using snapshots, create its copy in the target availability zone and delete the source VM.

Create a snapshot of each of the VM disksCreate a snapshot of each of the VM disks

Prepare the disksPrepare the disks

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:

Linux
Other operating systems
  1. Stop all disk write operations in applications.

  2. Write the OS cache to the disk:

    sync
    
  3. Freeze the file system:

    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.

  4. Create a snapshot by following the steps below.

  5. Unfreeze the file system:

    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.

  1. Stop the VM (see Stopping).
  2. Wait until the VM status changes to STOPPED.

Create snapshotsCreate snapshots

To create a disk snapshot:

Management console
CLI
Terraform
API
  1. In the management console, select the folder containing the disk.

  2. Select Compute Cloud.

  3. In the left-hand panel, select Disks.

  4. In the line with the disk, click and select Create snapshot.

  5. Enter a name for the snapshot. The naming requirements are as follows:

    • It must be from 2 to 63 characters long.
    • It may contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.
  6. Provide a description for the snapshot, if required.

  7. Click Create.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI commands for creating snapshots:

    yc compute snapshot create --help
    
  2. Select the disk to create a snapshot of. To get a list of disks in the default folder, run this command:

    yc compute disk list
    

    Result:

    +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
    |          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  |                      |                 |             |
    +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
    
  3. Create a snapshot in the default folder:

    yc compute snapshot create \
      --name first-snapshot \
      --description "my first snapshot via CLI" \
      --disk-id fhm4aq4hvq5g********
    

    This will create a disk snapshot named first-snapshot and described as my first snapshot via CLI.

    The snapshot naming requirements are as follows:

    • It must be from 2 to 63 characters long.
    • It may contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

  1. Define the parameters of the yandex_compute_snapshot resource in the configuration file.

    Here is an example of the configuration file structure:

    resource "yandex_compute_snapshot" "snapshot-1" {
      name           = "disk-snapshot"
      source_disk_id = "<disk_ID>"
    }
    

    For more information about the resources you can create with Terraform, see the relevant provider documentation.

  2. Make sure the configuration files are correct.

    1. In the command line, go to the directory where you created the configuration file.

    2. Run a check using this command:

      terraform plan
      

    If the configuration is correct, the terminal will display a list of resources to create and their parameters. If the configuration contains any errors, Terraform will point them out.

  3. Deploy the cloud resources.

    1. If the configuration does not contain any errors, run this command:

      terraform apply
      
    2. Confirm creating the resources.

    All the resources you need will then be created in the specified folder. You can check the new resources and their settings using the management console.

  1. Get a list of disks using the list REST API method for the Disk resource or the DiskService/List gRPC API call.
  2. Create a snapshot using the create REST API method for the Snapshot resource or the SnapshotService/Create gRPC API call.

Repeat the steps above to create snapshots of all the disks.

Create a VM in a different availability zone with the disks from the snapshotsCreate a VM in a different availability zone with the disks from the snapshots

To create a VM in a different availability zone with disks from snapshots:

Management console
CLI
API
  1. In the management console, select the folder where you want to create your VM.

  2. From the list of services, select Compute Cloud.

  3. In the left-hand panel, select Virtual machines.

  4. Click Create virtual machine.

  5. Under Boot disk image:

    • Go to the Custom tab.
    • Click , and, in the window that opens, select Create.
    • In the Contents field, select Snapshot and then select the disk snapshot you need from the list below. Use the filter as needed.
    • Enter a name for the new boot disk.
    • Select the disk type.
    • Specify the required disk and block size.
    • Optionally, enable Additional in the Delete along with the virtual machine field if you need this disk automatically deleted when deleting the VM.
    • Click Add disk.
  6. Under Location, select an availability zone where your VM will reside.

  7. Add a secondary disk:

    • Under Disks and file storages, click Add.
    • In the window that opens, select Disk → Create new.
    • In the Contents field, select Snapshot.
    • Enter a name for the new disk.
    • Select the disk type.
    • Specify the required disk and block size.
    • Optionally, enable Additional in the Delete along with the virtual machine field if you need this disk automatically deleted when deleting the VM.
    • Click Add disk.
  8. Optionally, to encrypt a boot disk or a secondary disk, under Disks and file storages, click to the right of the disk name and configure encryption parameters for the disk:

    • Select Encrypted disk.
    • In the KMS key field, select the key you want to use to encrypt the disk. To create a new key, click Create.

    To create an encrypted disk, you need the kms.keys.user role or higher.

    Warning

    You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption. You also cannot enable encryption for an existing disk.

    If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.

    Alert

    If you destroy the key or its version used to encrypt a disk, image, or snapshot, access to the data will be irrevocably lost. For details, see Destroying key versions.

  9. Optionally, connect a file storage:

    • Under Disks and file storages, click Add.

      • In the window that opens, select File storage and choose the storage you want to connect from the list.

      • Click Add file storage.

  10. 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.
  11. 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 automatically for 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.

  12. Under Access:

    • Select Access by OS Login to connect and manage access to the new VM using OS Login in Yandex Cloud Organization.

      With OS Login, you can connect to VMs using SSH keys and SSH certificates via a standard SSH client or the Yandex Cloud CLI. OS Login enables rotating the SSH keys used to access VMs, providing the most secure access option.

    • If you prefer not to use OS Login, select SSH key and specify the following VM access data:

      • Under Login, enter a username.

        Alert

        Do not use root or other reserved usernames. To perform operations requiring root privileges, use the sudo command.

      • In the SSH key field, select the SSH key saved in your organization user profile.

        If there are no saved SSH keys in your profile, or you want to add a new key:

        • Click Add key.
        • Enter a name for the SSH key.
        • Upload or paste the contents of the public key file. You need to create a key pair for the SSH connection to a VM yourself.
        • Click Add.

        The SSH key will be added to your organization user profile.

        If users cannot add SSH keys to their profiles in the organization, the added public SSH key will only be saved to the user profile of the VM being created.

    If you want to add multiple users with SSH keys to the VM at the same time, specify these users' data under Metadata. You can also use metadata to install additional software on a VM when creating it.

    In public Linux images provided by Yandex Cloud, the functionality of connecting over SSH using login and password is disabled by default.

  13. Under General information, enter a name for the VM:

    • It must be from 2 to 63 characters long.
    • It may 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.

  14. Under Additional:

    • Optionally, select or create a service account. With a service account, you can flexibly configure access permissions for your resources.

    • Optionally, enable access to the serial console.

    • Optionally, under Backup, enable Connect and select or create a backup policy to make automatic backups of your VMs using Cloud Backup.

      For more information, see Connecting Compute Cloud VMs and Yandex BareMetal servers to Cloud Backup.

    • Optionally, to configure delivering Linux metrics and any additional metrics from your apps, enable Monitoring under Agent for delivering metrics and select:

      • Yandex Monitoring: Install an agent to collect additional metrics from VM instances and apps.
      • Yandex Managed Service for Prometheus®: Install and configure an agent to collect additional metrics from VM instances and apps in Prometheus format:
        • Select or create a workspace to store your metrics.
        • Optionally, describe the delivery parameters for your custom metrics, in JSON format.
    • Optionally, under Placement, select a VM placement group.

  15. Click Create VM.

The VM will appear in the list. Every new VM gets an IP address and host name (FQDN).

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI command for creating a VM:

    yc compute instance create --help
    
  2. Prepare snapshots of the disks you need by following the steps in Creating a disk snapshot.

  3. Get a list of snapshots in the default folder:

    yc compute snapshot list
    

    Result:

    +----------------------+-----------------+----------------------+--------+----------------------------+
    |          ID          |       NAME      |     PRODUCT IDS      | STATUS |        DESCRIPTION         |
    +----------------------+-----------------+----------------------+--------+----------------------------+
    | fd8rlt1u2rf0l******* | first-snapshot  | f2ecl5vhsftd******** | READY  | my first snapshot via CLI  |
    | fhmolt1u2rf0******** | second-snapshot | f2eclmol5lps******** | READY  | my second snapshot via CLI |
    +----------------------+-----------------+----------------------+--------+----------------------------+
    
  4. Select ID or NAME of the snapshots you need.

  5. Create a VM in the default folder:

    yc compute instance create \
      --name first-instance \
      --zone ru-central1-a \
      --public-ip \
      --create-boot-disk snapshot-name=first-snapshot,kms-key-id=<key_ID> \
      --create-disk snapshot-name=second-snapshot,kms-key-id=<key_ID> \
      --ssh-key ~/.ssh/id_ed25519.pub
    

    Where:

    • --name: VM name. The naming requirements are as follows:

      • It must be from 2 to 63 characters long.
      • It may 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.

    • --public-ip: Connecting a public IP address. Remove this flag to create a VM without a public IP address.

    • --create-boot-disk: VM boot disk settings:

      • snapshot-name: Disk snapshot name.

      • kms-key-id: ID of the KMS symmetric key to create an encrypted boot disk. This is an optional parameter.

        To create an encrypted disk, you need the kms.keys.user role or higher.

        Warning

        You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption. You also cannot enable encryption for an existing disk.

        If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.

        Alert

        If you destroy the key or its version used to encrypt a disk, image, or snapshot, access to the data will be irrevocably lost. For details, see Destroying key versions.

    • --create-disk: Secondary disk settings:

      • snapshot-name: Disk snapshot name.
      • kms-key-id: ID of the KMS symmetric key to create an encrypted disk. This is an optional parameter.
    • --ssh-key: Path to the file with the public SSH key. The VM will automatically create a user named yc-user for this key.

      When creating a VM from a Yandex Cloud Marketplace public image, make sure to provide an SSH key, as SSH access with a username and password is disabled by default for such images.

    The above command will create a VM named first-instance in the ru-central1-a availability zone, with a public IP address and disks from the snapshots.

    If you want to add multiple network interfaces 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.

Use the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.

Delete the source VMDelete the source VM

To delete a source VM:

Management console
CLI
Terraform
API
  1. In the management console, select the folder the VM belongs to.

  2. Select Compute Cloud.

  3. In the line with the VM, click and select Delete.

    To delete multiple VMs, select them from the list and click Delete at the bottom of the screen.

  4. In the window that opens, click Delete.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI command for deleting a VM:

    yc compute instance delete --help
    
  2. Get a list of VMs in the default folder:

    yc compute instance list
    

    Result:

    +----------------------+-----------------+---------------+---------+----------------------+
    |          ID          |       NAME      |    ZONE ID    | STATUS  |     DESCRIPTION      |
    +----------------------+-----------------+---------------+---------+----------------------+
    | fhm0b28lgfp4******** | first-instance  | ru-central1-a | RUNNING | my first vm via CLI  |
    | fhm9gk85nj7g******** | second-instance | ru-central1-a | RUNNING | my second vm via CLI |
    +----------------------+-----------------+---------------+---------+----------------------+
    
  3. Select ID or NAME of the VM, e.g., first-instance.

  4. Delete the VM:

    yc compute instance delete first-instance
    

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

To delete a VM created using Terraform, follow these steps:

  1. In the command line, go to the directory with the Terraform configuration file.

  2. Delete the resources using this command:

    terraform destroy
    

    Alert

    Terraform will delete all the resources you created in the current configuration, such as clusters, networks, subnets, and VMs.

  3. Type yes and press Enter.

Use the delete REST API method for the Instance resource or the InstanceService/Delete gRPC API call.

Moving a VM using a special commandMoving a VM using a special command

When you move a VM to a different availability zone using the management console or the CLI, its metadata and ID will remain unchanged. All disks attached to the VM will also be transferred to the new availability zone.

Note

The time it takes to move a VM to a different availability zone depends on the size of its disks. As an example, a 100 GB disk typically migrates within 10 minutes.

In some cases, the migration may take longer if you are moving it to the ru-central1-d availability zone.

CLI

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI command for moving a VM to a different availability zone:

    yc compute instance relocate --help
    
  2. Get a list of all subnets in the default folder:

    yc vpc subnet list
    

    Result:

    +----------------------+-----------------------+----------------------+----------------+---------------+-------------------+
    |          ID          |         NAME          |      NETWORK ID      | ROUTE TABLE ID |     ZONE      |       RANGE       |
    +----------------------+-----------------------+----------------------+----------------+---------------+-------------------+
    | bucqps2lt75g******** | subnet-ru-central1-a1 | c64pv6m0aqq6******** |                | ru-central1-a | [192.168.11.0/24] |
    | e2lrucutusnd******** | subnet-ru-central1-a2 | c64pv6m0aqq6******** |                | ru-central1-a | [192.168.12.0/24] |
    | e2lv9c6aek1d******** | subnet-ru-central1-a3 | c64pv6m0aqq6******** |                | ru-central1-a | [192.168.13.0/24] |
    | bltign9kcffv******** | default-ru-central1-b | c64pv6m0aqq6******** |                | ru-central1-b | [192.168.1.0/24]  |
    +----------------------+-----------------------+----------------------+----------------+---------------+-------------------+
    
  3. Get a list of all security groups in the default folder:

    yc vpc sg list
    

    Result:

    +----------------------+---------------------------------+--------------------------------+----------------------+
    |          ID          |              NAME               |          DESCRIPTION           |      NETWORK-ID      |
    +----------------------+---------------------------------+--------------------------------+----------------------+
    | c646ev94tb6k******** | my-sg-group                     |                                | c64pv6m0aqq6******** |
    | c64r84tbt32j******** | default-sg-c64pv6m0aqq6******** | Default security group for     | c64pv6m0aqq6******** |
    |                      |                                 | network                        |                      |
    +----------------------+---------------------------------+--------------------------------+----------------------+
    
  4. Get a list of all VMs in the default folder:

    yc compute instance list
    

    Result:

    +----------------------+---------+---------------+---------+---------------+-------------+
    |          ID          |  NAME   |    ZONE ID    | STATUS  |  EXTERNAL IP  | INTERNAL IP |
    +----------------------+---------+---------------+---------+---------------+-------------+
    | a7lh48f5jvlk******** | my-vm-1 | ru-central1-a | RUNNING |               | 192.168.0.7 |
    | epdsj30mndgj******** | my-vm-2 | ru-central1-b | RUNNING |               | 192.168.1.7 |
    +----------------------+---------+---------------+---------+---------------+-------------+
    
  5. Get a list of network interfaces of the VM in question by specifying the VM ID:

    yc compute instance get <VM_ID>
    

    Result:

    ...
    network_interfaces:
      - index: "0"
        mac_address: d0:0d:24:**:**:**
        subnet_id: bucqps2lt75g********
        primary_v4_address:
          address: 192.168.11.23
          one_to_one_nat:
            address: 158.160.**.***
            ip_version: IPV4
      - index: "1"
        mac_address: d0:1d:24:**:**:**
        subnet_id: e2lrucutusnd********
        primary_v4_address:
          address: 192.168.12.32
      - index: "2"
        mac_address: d0:2d:24:**:**:**
        subnet_id: e2lv9c6aek1d********
        primary_v4_address:
          address: 192.168.13.26
    ...
    
  6. Move the VM to a different availability zone:

    yc compute instance relocate <VM_ID> \
      --destination-zone-id <availability_zone_ID> \
      --network-interface subnet-id=<subnet_ID>,security-group-ids=<security_group_ID>
    

    Where:

    • <VM_ID>: ID of the VM to move to a different availability zone.

    • --destination-zone-id: ID of the availability zone to move the VM to.

    • --network-interface: VM network interface settings:

      • subnet-id: ID of the subnet in the availability zone to move the VM to.
      • security-group-ids: ID of the security group to link to the VM you are moving. You can link multiple security groups to a single VM by providing a comma-separated list of security group IDs in [id1,id2] format.

      If a VM has multiple network interfaces, specify the --network-interface parameter as many times as needed (for each network interface).

    For more information about the yc compute instance relocate command, see the CLI reference.

    Example:

    yc compute instance relocate a7lh48f5jvlk******** \
      --destination-zone-id ru-central1-b \
      --network-interface \
        subnet-id=bltign9kcffv********,security-group-ids=c646ev94tb6k********
    

    In this example, we are moving a VM named my-vm-1 from the ru-central1-a availability zone to ru-central1-b.

    Result:

    done (3m15s)
    id: a7lh48f5jvlk********
    folder_id: aoeg2e07onia********
    created_at: "2023-10-13T19:47:40Z"
    name: my-vm-1
    zone_id: ru-central1-b
    platform_id: standard-v3
    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: a7lp7jpslu59********
      auto_delete: true
      disk_id: a7lp7jpslu59********
    network_interfaces:
      - index: "0"
        mac_address: d0:0d:11:**:**:**
        subnet_id: bltign9kcffv********
        primary_v4_address:
          address: 192.168.1.17
        security_group_ids:
          - c646ev94tb6k********
    gpu_settings: {}
    fqdn: my-vm-1.ru-central1.internal
    scheduling_policy: {}
    network_settings:
      type: STANDARD
    placement_policy: {}
    

    If you are moving a VM with a disk in a placement group, use this command:

    yc compute instance relocate <VM_ID> \
      --destination-zone-id <availability_zone_ID> \
      --network-interface subnet-id=<subnet_ID>,security-group-ids=<security_group_ID> \
      --boot-disk-placement-group-id <disk_placement_group_ID> \
      --boot-disk-placement-group-partition <partition_number> \
      --secondary-disk-placement disk-name=<disk_name>,disk-placement-group-id=<disk_placement_group_ID>,disk-placement-group-partition=<partition_number>
    

    Where:

    • --boot-disk-placement-group-id: Disk placement group ID.

    • --boot-disk-placement-group-partition: Partition number in the disk placement group with the partition placement strategy.

    • --secondary-disk-placement: Placement policy for secondary disks. Parameters:

      • disk-name: Disk name.
      • disk-placement-group-id: ID of the disk placement group to place the disk in.
      • disk-placement-group-partition: Partition number in the disk placement group.

    For more information about the yc compute instance relocate command, see the CLI reference.

Please note that connecting VM network interfaces to new subnets changes their IP addressing. If you need to specify internal IP addresses for the VM network interfaces, use the ipv4-address=<internal_IP_address> property of the network-interface parameter; for public IP addresses, use the nat-address=<public_IP_address> property. Other than that, setting up network interface parameters when moving a VM to a different availability zone is similar to setting up the same parameters when creating a VM.

Note

Active writes to the VM disks being moved may cause the migration to fail. In this case, stop writing to the disks or shut down the VM and restart the migration.

ExamplesExamples

Moving a VM to a different zoneMoving a VM to a different zone

In this example, we are moving a VM named my-vm-1 from the ru-central1-a availability zone to ru-central1-d.

yc compute instance relocate a7lh48f5jvlk******** \
  --destination-zone-id ru-central1-d \
  --network-interface \
    subnet-id=bltign9kcffv********,security-group-ids=c646ev94tb6k********

Result:

done (3m15s)
id: a7lh48f5jvlk********
folder_id: aoeg2e07onia********
created_at: "2023-10-13T19:47:40Z"
name: my-vm-1
zone_id: ru-central1-d
platform_id: standard-v3
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: a7lp7jpslu59********
  auto_delete: true
  disk_id: a7lp7jpslu59********
network_interfaces:
  - index: "0"
mac_address: d0:0d:11:**:**:**
subnet_id: bltign9kcffv********
primary_v4_address:
  address: 192.168.1.17
security_group_ids:
  - c646ev94tb6k********
gpu_settings: {}
fqdn: my-vm-1.ru-central1.internal
scheduling_policy: {}
network_settings:
  type: STANDARD
placement_policy: {}

Moving a VM with disks in a placement groupMoving a VM with disks in a placement group

In this example, we are moving a VM named my-vm-1 with two disks in the placement group from the ru-central1-b availability zone to ru-central1-d.

yc compute instance relocate epd6qtn128k1******** \
  --destination-zone-id ru-central1-d \
  --network-interface \
    subnet-id=fl8glc5v0lqj********,security-group-ids=enp1gjh3q042******** \
  --boot-disk-placement-group-id fv4pfmor782v******** \
  --boot-disk-placement-group-partition 1 \
  --secondary-disk-placement \
    disk-name=disk-two,fv4pfmor782v********,disk-placement-group-partition=2

Result:

done (9m0s)
id: epd6qtn128k1********
folder_id: b1gmit33ngp3********
created_at: "2023-12-07T19:30:20Z"
name: my-vm-1
zone_id: ru-central1-d
platform_id: standard-v3
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: epdeqrm6g38j********
  auto_delete: true
  disk_id: epdeqrm6g38j********
secondary_disks:
  - mode: READ_WRITE
    device_name: epdi54snn7t6********
    disk_id: epdi54snn7t6********
network_interfaces:
  - index: "0"
    mac_address: d0:0d:6d:76:e1:12
    subnet_id: fl8glc5v0lqj********
    primary_v4_address:
      address: 10.130.0.12
    security_group_ids:
      - enp1gjh3q042********
gpu_settings: {}
fqdn: my-vm-1.ru-central1.internal
scheduling_policy: {}
network_settings:
  type: STANDARD
placement_policy: {}

Was the article helpful?

Previous
Detaching a disk from a VM
Next
Moving a VM to a different folder
Yandex project
© 2025 Yandex.Cloud LLC