Uploading a disk image to Yandex.Cloud

The following instructions describe how to upload a disk image to Object Storage and use it to create an image in Compute Cloud.

1. Prepare an image

Supported image formats: Qcow2, VMDK, and VHD.

If you upload a boot disk image, make sure the following requirements are met:

  • The OS is Linux-based.
  • The latest OS updates are installed.
  • The disk is mounted by its UUID rather than by name.
  • The Linux kernel is running with the console=ttyS0 parameter.
  • The SSH server starts automatically at VM startup.
  • The network interface obtains the IP address via DHCP.

Recommendations:

  • We recommend uploading 64-bit systems with the pre-installed cloud-init package and virtio-net and virtio-blk drivers.

  • Optimize images before uploading them by using the qemu-img utility to import faster:

    qemu-img convert -p -O qcow2 -o cluster_size=2M <name of your image file> <name of the new image file>
    

2. Upload an image to Object Storage

Upload your image to Yandex Object Storage and get a link to the uploaded image:

  1. If you don't have a bucket in Object Storage, create one.
  2. Upload the image to your bucket. In Object Storage terms, the uploaded image is called an object.
  3. Get a link to the uploaded image. Use this link when creating an image in Compute Cloud.

3. Create an image in Compute Cloud

Create a new image from the link obtained in Object Storage:

  1. In the management console, select the folder where you want to create an image.

  2. Select Compute Cloud.

  3. On the Virtual machines page, go to the Images tab.

  4. Click Upload image.

  5. Enter the image name.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

  6. If necessary, add a description of the image.

  7. Insert the link to the image you received in Object Storage.

  8. Click Upload.

To create a new image via the link, use the flag --source-uri.

$ yc compute image create --name <IMAGE-NAME> --source-uri <IMAGE-URL>

where:

  • <IMAGE-NAME> is the name to assign to the image.
  • <IMAGE-URL> is the link to the image obtained in Object Storage.

If necessary, add a description and specify the family that the image belongs to:

$ yc compute image create  \
    --name ubuntu-cosmic \
    --description "Ubuntu Server 18.10 (Cosmic Cuttlefish)" \
    --family ubuntu \
    --source-uri "https://storage.yandexcloud.net/mybucket/cosmic-server-cloudimg-amd64.vmdk"

If you know the minimum requirements for the size of a disk that will be created from this image, specify the size in GB:

$ yc compute image create  \
    --name big-image \
    --min-disk-size 20 \
    --source-uri "https://storage.yandexcloud.net/mybucket/cosmic-server-cloudimg-amd64.vmdk"

Note

The min-disk-size value must be greater than the volume of the source data in the image and greater than the size of the virtual disk specified in the image.

If the min-disk-size value you specify is less than that allowed, an error will occur and no image will be created. The error description will contain the minimum value in bytes, for example, Minimal disk size should be greater than or equal to 10737418240.

If no min-disk-size is specified, the minimum value will be used.

To create a new image via the link, use the Create method for the Image resource. Pass the link to the image in the uri element.

After being created, the image will get the CREATING status. Wait until the image status changes to READY before using it.

4. Delete the image from Object Storage

If the image was created successfully, you can delete the image file from Object Storage. You can also delete the bucket if there are no objects left in it.

For information about Object Storage pricing, see Pricing policy for Object Storage.