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
- Access to an evroc organization and project
- evroc CLI installed and configured
Upload the disk image
Create an evroc bucket in the same project as the boot disks that will use it. Then create a bucket service account
with access to that bucket. Upload the disk image as a .qcow2, .vhdx or .raw file to that bucket. See
the storage API guide for further instructions.
N.B. You must use a BucketServiceAccount, and not a regular ServiceAccount, to access the bucket. Whereas
ServiceAccounts allow you to grant fine-grained permissions, BucketServiceAccounts only allow granting "all or
nothing" permissions (you either have complete access to - and control over - the bucket, or you don't).
Create a custom disk image
Create a custom disk image that references the uploaded file.
Create a custom disk image using the CLI
evroc compute customdiskimage create mydiskimage \
--bucket=my-bucket \
--service-account=my-bucket-service-account \
--path=images/mydiskimage.qcow2 \
--architecture=amd64 \
--size-amount=20 \
--size-unit=GB
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",
"serviceAccountRef": "/storage/projects/{projectID}/regions/{regionName}/bucketServiceAccounts/my-bucket-service-account",
"path": "images/mydiskimage.qcow2"
}
}
}'
See Create a Custom Disk Image in the API reference.
List custom disk images
List all custom disk images in your project:
evroc compute customdiskimage list
Use 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
You can create a boot disk from a custom disk image.
Create a boot disk from a custom disk image using the CLI
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
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
Delete a custom disk image you no longer need. The custom disk image can't be deleted if any disks still reference it.
evroc compute customdiskimage delete mydiskimage
See Delete a Custom Disk Image in the API reference.
Debugging
If a VM cannot be started from a custom disk image, check the console logs.