Creating an OMI from a Snapshot

You can create OUTSCALE machine images (OMIs) from snapshots. With AWS CLI, this action corresponds to registering an OMI and specifying a snapshot ID in its block device mapping.

Creating an Image from a Snapshot Using Cockpit v2

Before you begin:

  1. If you intend to share the image with other accounts, clean critical information from the virtual machine (VM) that you do not want to share:

  2. (Windows VMs only) To reinitialize your Windows VM system, execute the OMI Creation Launcher script in the C:\Windows\Outscale\scripts directory of the VM.

    • This script is only available on VMs created using an official image. If the VM has been created using a non-official image, you can perform a sysprep. For more information, see the official sysprep documentation by Windows.

    • This script enables VMs created using the future image to be reinitialized (ID, keypair, administrator password, and so on).

    The VM automatically stops when the script is done.

  3. Create a snapshot of the root volume of the VM from which you want to create the image. For more information, see Creating a Snapshot of a Volume.

  1. In the Images dashboard, click IconAddFull Create Image.
    The CREATE IMAGE dialog box appears.

    You can also select a snapshot in the Snapshots dashboard and click IconAddFull Create Image.

  2. In the Name field, type a name for the image.

    This name must be unique and must contain between 3 and 128 characters. Allowed characters are a-z, A-Z, 0-9, spaces, and [_()/.-].

  3. (optional) In the Description field, type a description for the image.

  4. Select From snapshot and select a snapshot from the Snapshot selection list.

  5. In the Architecture selection list, select an architecture for the image (i386 or x86_64).

  6. Set the Delete on termination option for volumes of VMs created from the image:

    • To automatically delete the volumes of a VM you delete, switch the button to True.

      Data stored on the deleted volumes is lost and cannot be retrieved.

      Before you delete it, ensure you have a backup or snapshot of it. For more information, see Creating a Snapshot of a Volume.

    • To keep the volumes of a VM you delete, switch the button to False.

  7. Click Create Image.
    The image is created.

Creating an OMI from a Snapshot Using OSC CLI

Before you begin:

  1. If you intend to share the OMI with other accounts, clean critical information from the VM that you do not want to share:

  2. (Windows VMs only) To reinitialize your Windows VM system, execute the OMI Creation Launcher script in the C:\Windows\Outscale\scripts directory of the VM.

    • This script is only available on VMs created using an official OMI. If the VM has been created using a non-official OMI, you can perform a sysprep. For more information, see the official sysprep documentation by Windows.

    • This script enables VMs created using the future OMI to be reinitialized (ID, keypair, administrator password, and so on).

    The VM automatically stops when the script is done.

  3. Create a snapshot of the root device of the VM from which you want to create the OMI. For more information, see Creating a Snapshot of a Volume.

The CreateImage command creates an OUTSCALE machine image (OMI).
You can use this method in different ways:

  • Creating from a VM: You create an OMI from one of your virtual machines (VMs).

  • Copying an OMI: You copy an existing OMI. The source OMI can be one of your own OMIs, or an OMI owned by another account that has granted you permission via the UpdateImage method.

  • Registering from a snapshot: You register an OMI from an existing snapshot. The source snapshot can be one of your own snapshots, or a snapshot owned by another account that has granted you permission via the UpdateSnapshot method.

  • Registering from a bucket by using a manifest file: You register an OMI from the manifest file of an OMI that was exported to an OUTSCALE Object Storage (OOS) bucket. First, the owner of the source OMI must export it to the bucket by using the CreateImageExportTask method. Then, they must grant you permission to read the manifest file via a pre-signed URL. For more information, see Creating a Pre-Signed URL.

Registering from a bucket enables you to copy an OMI across Regions.

For more information, see About OMIs.

Request sample: Registering from a snapshot
$ osc-cli api CreateImage --profile "default" \
    --ImageName "register-image-from-snapshot-example" \
    --BlockDeviceMappings '[
        {
          "DeviceName": "/dev/sda1",
          "Bsu": {"SnapshotId": "snap-12345678", "VolumeSize": 120, "VolumeType": "io1", "Iops": 150, "DeleteOnVmDeletion": True},
        },
      ]' \
    --RootDeviceName "/dev/sda1"

This command contains the following attributes that you need to specify:

  • Architecture: (optional) (when registering from a snapshot) The architecture of the OMI (i386 or x86_64).

  • BlockDeviceMappings: (optional) (when registering from a snapshot) One or more block device mappings.

    • Bsu: (optional) Information about the BSU volume to create.

      • DeleteOnVmDeletion: (optional) By default or if set to true, the volume is deleted when terminating the VM. If false, the volume is not deleted when terminating the VM.

      • Iops: (optional) The number of I/O operations per second (IOPS). This parameter must be specified only if you create an io1 volume. The maximum number of IOPS allowed for io1 volumes is 13000 with a maximum performance ratio of 300 IOPS per gibibyte.

      • SnapshotId: (optional) The ID of the snapshot used to create the volume.

      • VolumeSize: (optional) The size of the volume, in gibibytes (GiB).
        If you specify a snapshot ID, the volume size must be at least equal to the snapshot size.
        If you specify a snapshot ID but no volume size, the volume is created with a size similar to the snapshot one.

      • VolumeType: (optional) The type of the volume (standard | io1 | gp2). If not specified in the request, a standard volume is created.
        For more information about volume types, see About Volumes > Volume Types and IOPS.

    • DeviceName: (optional) The device name for the volume. For a root device, you must use /dev/sda1. For other volumes, you must use /dev/sdX, /dev/sdXX, /dev/xvdX, or /dev/xvdXX (where the first X is a letter between b and z, and the second X is a letter between a and z).

    • VirtualDeviceName: (optional) The name of the virtual device (ephemeralN).

  • Description: (optional) A description for the new OMI.

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • ImageName: (optional) A unique name for the new OMI.
    Constraints: 3-128 alphanumeric characters, underscores (_), spaces ( ), parentheses (()), slashes (/), periods (.), or dashes (-).

  • ProductCodes: (optional) The product codes associated with the OMI.

  • RootDeviceName: (optional) (when registering from a snapshot) The name of the root device for the new OMI.

The CreateImage command returns the following elements:

  • Image: Information about the OMI.

    • AccountAlias: The account alias of the owner of the OMI.

    • AccountId: The account ID of the owner of the OMI.

    • Architecture: The architecture of the OMI.

    • BlockDeviceMappings: One or more block device mappings.

      • Bsu: Information about the BSU volume to create.

        • DeleteOnVmDeletion: By default or if set to true, the volume is deleted when terminating the VM. If false, the volume is not deleted when terminating the VM.

        • Iops: The number of I/O operations per second (IOPS). This parameter must be specified only if you create an io1 volume. The maximum number of IOPS allowed for io1 volumes is 13000 with a maximum performance ratio of 300 IOPS per gibibyte.

        • SnapshotId: The ID of the snapshot used to create the volume.

        • VolumeSize: The size of the volume, in gibibytes (GiB).
          If you specify a snapshot ID, the volume size must be at least equal to the snapshot size.
          If you specify a snapshot ID but no volume size, the volume is created with a size similar to the snapshot one.

        • VolumeType: The type of the volume (standard | io1 | gp2). If not specified in the request, a standard volume is created.
          For more information about volume types, see About Volumes > Volume Types and IOPS.

      • DeviceName: The device name for the volume. For a root device, you must use /dev/sda1. For other volumes, you must use /dev/sdX, /dev/sdXX, /dev/xvdX, or /dev/xvdXX (where the first X is a letter between b and z, and the second X is a letter between a and z).

      • VirtualDeviceName: The name of the virtual device (ephemeralN).

    • CreationDate: The date and time (UTC) at which the OMI was created.

    • Description: The description of the OMI.

    • FileLocation: The location from which the OMI files were created.

    • ImageId: The ID of the OMI.

    • ImageName: The name of the OMI.

    • ImageType: The type of the OMI.

    • PermissionsToLaunch: Permissions for the resource.

      • AccountIds: One or more account IDs that the permission is associated with.

      • GlobalPermission: A global permission for all accounts.
        (Request) Set this parameter to true to make the resource public (if the parent parameter is Additions) or to make the resource private (if the parent parameter is Removals).
        (Response) If true, the resource is public. If false, the resource is private.

    • ProductCodes: The product codes associated with the OMI.

    • RootDeviceName: The name of the root device.

    • RootDeviceType: The type of root device used by the OMI (always bsu).

    • State: The state of the OMI (pending | available | failed).

    • StateComment: Information about the change of state.

      • StateCode: The code of the change of state.

      • StateMessage: A message explaining the change of state.

    • Tags: One or more tags associated with the OMI.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample: Registering from a snapshot
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "Image": {
    "StateComment": {},
    "State": "available",
    "RootDeviceType": "bsu",
    "RootDeviceName": "/dev/sda1",
    "ProductCodes": [
      "0001"
    ],
    "PermissionsToLaunch": {
      "GlobalPermission": false,
      "AccountIds": []
    },
    "AccountId": "123456789012",
    "Tags": [],
    "Description": "",
    "ImageId": "ami-12345678",
    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Bsu": {
          "VolumeType": "io1",
          "DeleteOnVmDeletion": true,
          "VolumeSize": 120,
          "Iops": 150,
          "SnapshotId": "snap-12345678"
        }
      }
    ],
    "ImageType": "machine",
    "CreationDate": "2010-10-01T12:34:56.789Z",
    "FileLocation": "123456789012/register-image-from-snapshot-example",
    "Architecture": "x86_64",
    "ImageName": "register-image-from-snapshot-example"
  }
}

Creating an OMI from a Snapshot Using AWS CLI

Before you begin:

  1. If you intend to share the OMI with other accounts, clean critical information from the instance that you do not want to share:

  2. (Windows VMs only) To reinitialize your Windows VM system, execute the OMI Creation Launcher script in the C:\Windows\Outscale\scripts directory of the VM.

    • This script is only available on VMs created using an official OMI. If the VM has been created using a non-official OMI, you can perform a sysprep. For more information, see the official sysprep documentation by Windows.

    • This script enables VMs created using the future OMI to be reinitialized (ID, keypair, administrator password, and so on).

    The VM automatically stops when the script is done.

  1. Create a snapshot of the root device of the instance from which you want to create the OMI. For more information, see Creating a Snapshot of a Volume.

To create an OMI, use the register-image command following this syntax:

Request sample
$ aws ec2 register-image \
    --profile YOUR_PROFILE \
    --name "Test Image" \
    --description "My test image" \
    --architecture x86_64 \
    --root-device-name /dev/sda1 \
    --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\", \
                                \"Ebs\": \
                                        {\"SnapshotId\": \"snap-12345678\"} \
                             }]" \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • name: The name of the OMI.

    This name must be unique and must contain between 3 and 128 characters. Allowed characters are a-z, A-Z, 0-9, spaces, and [_()/.-].

  • (optional) description: A description for the OMI.

    This description can contain any Unicode character, with no length limit.

  • (optional) architecture: The architecture of the OMI. By default, set to i386 (32-bit architecture).

  • root-device-name: The device name assigned to the root volume.

  • block-device-mappings: The block device mapping indicating the snapshot to use for the root volume. This attribute requires the following elements:

    • DeviceName: The device name assigned to the root volume.

      You must specify the same device name as in the root-device-name attribute.

    • Ebs: Information about the root volume to create. This element requires the following information:

      • SnapshotId: The ID of the snapshot from which you want to create the OMI.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The register-image command returns the following element:

  • ImageId: The ID of the newly created OMI.

Result sample
 {
    "ImageId": "ami-12345678"
}

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.