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.
Prerequisites
Section titled “Prerequisites”- Access to an evroc organization and project
- evroc CLI installed and configured
Upload the disk image
Section titled “Upload the disk image”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.
Grant the image importer read access
Section titled “Grant the image importer read access”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>):
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:
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
Section titled “Create a custom disk image”Create a custom disk image that references the uploaded file.
Create a custom disk image using the CLI
Section titled “Create a custom disk image using the CLI”evroc compute customdiskimage create mydiskimage \ --bucket=my-bucket \ --path=images/mydiskimage.qcow2 \ --architecture=amd64 \ --size-amount=20 \ --size-unit=GBCreate a custom disk image using the API
Section titled “Create a custom disk image using the API”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 custom disk images
Section titled “List custom disk images”List all custom disk images in your project:
evroc compute customdiskimage listUse evroc compute customdiskimage get <disk_image_name> for detailed information.
See List Custom Disk Images in the API reference.
Create a disk from a custom disk image
Section titled “Create a disk from a custom disk image”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”evroc compute disk create mynewdisk \ --custom-image=mydiskimage \ --zone=aIf 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”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
Section titled “Delete a custom disk image”Delete a custom disk image you no longer need:
evroc compute customdiskimage delete mydiskimageSee Delete a Custom Disk Image in the API reference.
Debugging
Section titled “Debugging”If a VM cannot be started from a custom disk image, check the console logs.