Capture an image
Here we cover how to capture the disk from an existing Compute Instance and save it as an image. This stores it for you so you can quickly create new Compute Instances using the image.
Requirements and considerations
When capturing an image file from an existing Compute Instance, consider these points:
-
Maximum disk size for an image. This is currently 6 GB*. To check the internal disk usage:
-
Log in to the Cloud Manager.
-
Select Linodes.
-
Find the target Compute Instance and click Launch LISH Console.
-
Run
df -h
. -
Locate the disk in the output and review the value in the
Used
column.
-
-
The disk's internal storage needs to be 10% less than your account's image size limit. With the default image size limit of 6 GB, your disk's storage usage should be under 5.4 GB. Have a look at Check and Clean a Linux System's Disk Space for some tips on managing space.
-
The disk needs to be formatted using ext3 or ext4 file systems. An images can't be captured if you're using a raw disk or a disk you've formatted using a custom file system. CoreOS disk images are in RAW format. You can't use an image made from a CoreOS disk to deploy a new Compute Instance.
-
Power off a Compute Instance to avoid database corruption. If your Compute Instance is running an active database, you should power off the Compute Instance before you create an image. If you leave a database active in a running Compute Instance, you may see corruption or data loss in the imaged copy of the database.
-
Only the selected disk is saved to the image. When capturing an image, other aspects of the Compute Instance aren't stored. This includes Configuration Profiles, Block Storage Volumes, IP addresses, and all other Compute Instance-based settings.
-
Account limits. Your account can store up to 25* custom images, offering 150 GB* of combined storage for all images.
-
Pricing. Custom images are billed monthly at $0.10 per GB, based on the uncompressed image size."
* If you need to store larger images or more images, contact Support with details on your applications or intended workloads.
Capture an image
There are multiple methods you can use to capture an image.
Use Cloud Manager
When you're sure your target Compute Instance disk is compatible, you can create an image of it in Cloud Manager.
-
Log in to Cloud Manager.
-
Select Images and click Create Image.
-
Select the Capture Image tab.
-
Set the Select Linode & Disk options:
-
Linode. Select the Compute Instance that houses the disk you want to use for your image.
-
Disk. Select the specific disk you want to use for your image.
-
-
Set the Image Details options:
-
Label. This defaults to the names of LinodeCompute Instance and Disk you've selected. You can optionally change this to another easy-to-recognize name for the image.
-
This image is cloud-init compatible. Enable this if you want the image to support cloud-init. Many Compute Instance-supported distributions are compatible with it by default, or you may have installed cloud-init. Our Metadata service is designed to be consumed by cloud-init.
-
Add Tags. For organizational purposes, you can enter a tag to group similar objects under a specific value. Once you set one, you can select it again with other images.
-
Description. Optionally add some text to describe your image.
-
-
Click Create Image.
You're redirected to the main Images page. Your new image is displayed in the Custom Images table, with a Status of Creating {X}%. Once it's ready, Cloud Manager changes its status to Ready. The Size of the image is based on the disk's usage, not the size of the disk itself.
Use the API
Here we combine API operations to locate the target Compute Instance and target a compatible disk to generate an image.
List regions
Run this API curl request, making sure to properly paste in or reference your API token. Store the id
and label
values for the region where your target Compute Instance lives.
curl -H "Authorization: Bearer $TOKEN" \
https://api.linode.com/v4/regions
List Compute Instances
Run this request using the stored region id
to filter the response. Identify the specific Compute Instance you want, and store the disk
value from the specs
object for the disk you want to use for the image.
curl -H "Authorization: Bearer $TOKEN"
-H 'X-Filter: { "region": "us-east" }'
https://api.linode.com/v4/linode/instances
Create the image
Run this request to create the image. Store the id
value that's generated for it.
disk_id
. Set this to thedisk
you stored from the Compute Instance.label
. Optionally give your image an easily recognizable name. If this is left out, the name of the image will default to<compute_instance_label>-<disk_name>
.tags
. For organizational purposes, you can optionally enter one or more tags to group similar objects under these specific values. Once you set one, you can set it again with other images.description
. Optionally add some text to describe your image.cloud_init
. Set totrue
if you want the image to support cloud-init. Many Compute Instance-supported distributions are compatible with it by default, or you may have installed cloud-init on the disk, yourself. Our Metadata service is designed to be consumed by cloud-init.
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-X POST -d '{
"disk_id": 12345
"label": "Golden Image 2",
"tags": [
"gold", "secondary"
]
"description": "Secondary golden image for Ubuntu Linux",
"cloud_init": "true"
}' \
https://api.linode.com/v4/images
Check the status
The process takes some time to complete. You can check on it by running this request, using the id
you stored after creating the image. When the status
is available
, the image is ready for use.
curl -H "Authorization: Bearer $TOKEN" \
https://api.linode.com/v4/images/{image_id}
Updated about 1 month ago