Skip to content

Create and use custom disk images

This guide shows you how to create custom disk images, boot disks from them, and manage custom disk images using the evroc CLI and API.

  • Access to an evroc organization and project
  • evroc CLI installed and configured

Create an evroc bucket in the same project as the boot disks that will use it. Upload the disk image as a .qcow2, .vhdx or .raw file to that bucket. See the storage API guide for further instructions.

There is a dedicated, evroc-managed service account for each project to read the disk images. This service account is referenced as /iam/projects/compute-custom-disk-image-importer/serviceAccounts/<your-project-id>. This service account must be granted the /iam/roles/storageViewer role for the disk image files you wish to use. The role can be granted either for specific files, or for the entire bucket.

To grant read access to a single disk image, use the object’s resource path (i.e. /storage/projects/<your-project-id>/regions/<region-name>/buckets/<bucket-id>/objects/<path-to-file>/<file.ext>):

Terminal window
evroc iam rolebinding assign \
--principal "/iam/projects/compute-custom-disk-image-importer/serviceAccounts/<project-id>" \
--role /iam/roles/storageViewer \
--resource "/storage/projects/<project-id>/regions/<region-name>/buckets/my-bucket/objects/images/mydiskimage.qcow2"

To grant read access to all objects in the bucket, use the bucket’s resource path:

Terminal window
evroc iam rolebinding assign \
--principal "/iam/projects/compute-custom-disk-image-importer/serviceAccounts/<project-id>" \
--role /iam/roles/storageViewer \
--resource "/storage/projects/<project-id>/regions/<region-name>/buckets/my-bucket"

Create a custom disk image that references the uploaded file.

Terminal window
evroc compute customdiskimage create mydiskimage \
--bucket=my-bucket \
--path=images/mydiskimage.qcow2 \
--architecture=amd64 \
--size-amount=20 \
--size-unit=GB
Terminal window
curl -X POST https://api.evroc.com/compute/v1beta2/projects/{projectID}/regions/{regionName}/customDiskImages \
-H "Content-Type: application/json" \
-d '{
"apiVersion": "compute/v1beta2",
"kind": "CustomDiskImage",
"metadata": { "id": "mydiskimage" },
"spec": {
"architecture": "amd64",
"defaultDiskSize": { "amount": 20, "unit": "GB" },
"source": {
"bucketRef": "/storage/projects/{projectID}/regions/{regionName}/buckets/my-bucket",
"path": "images/mydiskimage.qcow2"
}
}
}'

See Create a Custom Disk Image in the API reference.

List all custom disk images in your project:

Terminal window
evroc compute customdiskimage list

Use evroc compute customdiskimage get <disk_image_name> for detailed information.

See List Custom Disk Images in the API reference.

You can create a boot disk from a custom disk image.

Create a boot disk from a custom disk image using the CLI

Section titled “Create a boot disk from a custom disk image using the CLI”
Terminal window
evroc compute disk create mynewdisk \
--custom-image=mydiskimage \
--zone=a

If you don’t specify a disk size, it defaults to the custom disk image’s defaultDiskSize.

Create a boot disk from a custom disk image using the API

Section titled “Create a boot disk from a custom disk image using the API”
Terminal window
curl -X POST https://api.evroc.com/compute/v1beta2/projects/{projectID}/regions/{regionName}/disks \
-H "Content-Type: application/json" \
-d '{
"apiVersion": "compute/v1beta2",
"kind": "Disk",
"metadata": { "id": "mynewdisk" },
"spec": {
"source": {
"type": "image",
"diskImageRef": "/compute/projects/{projectID}/regions/{regionName}/customDiskImages/mydiskimage"
},
"placement": { "zone": "a" }
}
}'

See Create a Disk in the API reference.

Delete a custom disk image you no longer need:

Terminal window
evroc compute customdiskimage delete mydiskimage

See Delete a Custom Disk Image in the API reference.

If a VM cannot be started from a custom disk image, check the console logs.