How to export Compute Cloud VM images
Issue description
You need to download an image of one or multiple VM disks to your local storage.
Solution
You can only use an image or snapshot of a VM disk within Yandex Cloud.
You cannot directly download it to your computer via the management console
To resolve this issue, you can use third-party software or native OS tools to create an image or backup of your disk, e.g., dd on Linux machines, and then download the image to your local storage.
To do this, follow these steps:
Please note
The dd utility treats disk images as block devices rather than file systems.
If you run a disk copy operation on a VM that is running on that particular disk, you may encounter data inconsistency in the image file you get. To avoid it, we highly recommend that you stop the VM and create a new image from its system disk instead of running a disk copy operation on a running system.
-
Stop the VM whose disk image you need to copy. You can do this via the management console or the YC CLI:
yc compute instance stop <VM_name> -
Create a VM disk image to copy following this guide.
-
Create a temporary Linux VM to run a copy operation.
-
When creating a VM, attach a secondary disk to it.
Then, specify the image you created earlier as its contents. -
Mount the secondary disk (the one you need to copy) to it following this guide.
-
Create a new SSH session and copy the secondary disk to your local machine using this command:
ssh <username>@<VM_IP_address> "sudo dd if=/dev/sdb status=progress | gzip -c" > sda.img.gzThe disk image will be saved to your local directory where the SSH session was established.
If you need to transfer the disk image within Yandex Cloud, you can provide public access to it.
To do this, assign the compute.images.user role to the allAuthenticatedUsers system group. This role does not grant permissions to delete or modify your images.