Convert instance store support for EBS-backed Amis

Source: Internet
Author: User

Convert instance store support for EBS-backed Amis

Note: You cannot convert an instance store-backed Windows Ami to an EBS-backed Ami. And, you can only convert the AMI you own.

1. Launch an Amazon Linux instance from an EBS-backed AMI.

2. Upload the private key of the *. * Certificate used to bundle the AMI supported by the instance store. (This private key will ensure that only you can access your AMI.) )

3. Set the environment variables for your key ID and Secret key:

[Ec2-user ~]$ export aws_access_key=your_access_key_id[ec2-user ~]$ export aws_secret_key=your_secret_ Access_key

4. Prepare an EBS volume for your new AMI

A. Create an empty EBS in the same AZ (the capacity must be equal to or greater than the size of the instance store root volume to be copied)

 --region us-west-2 --availability-zone us-west-2bVOLUME    volume_id    10         us-west-2b    creating    - -24t23: each:0000 Standard    

Note The Volume ID returned by the command.

B. Attach the new EBS volume to the EBS-backed instance described above:

[Ec2-user ~]$ ec2-attach-volume volume_id-i instance_id--device/dev/sdb--region us-west-2ATTACHMENT    volume_id    instance_id    /dev/sdb    attaching    - -24t23: :+0000

5. Download the bundle of instance store-based Amis to an EBS-backed instance:

Ec2-download-bundle-b my-s3-bucket/bundle_folder/bundle_name-m image.manifest.xml-a $AWS _access_key-s $AWS _secret_ KEY--privatekey/path/to/pk-hkzyktaig2ecmxyibh3hxv4zbexample.pem-d/tmp/bundle

6. Rebuild the image file from the bundle:

Ec2-unbundle-m Image.manifest.xml--privatekey/path/to/pk-hkzyktaig2ecmxyibh3hxv4zbexample.pem

7. Copy the image file to the new attached EBS volume:

sudo DD if=/tmp/bundle/image of=/dev/sdb bs=1m

8. Probe the volume of all new partitions that are deallocated:

sudo partprobe/dev/sdb

9. List the block device to find the device name to mount

 [Ec2-user bundle]$ lsblkname maj:min RM SIZE RO TYPE mountpoint /DEV/SDA 202 : 0  0  8G 0   disk└─ /dev/sda1 202 : 1  0  8G 0  part//dev/sdb 202 : 80  0  10G 0   disk└─ /dev/sdb1 202 : 81  0  10G 0  Part 

In this example, the partition to mount is /dev/sdb1 , but your device name may be different. If your volume is not partitioned, the device you want to mount is similar to /dev/sdb (no trailing digits for the device partition).

10. Create a mount point for the new Amazon EBS volume and install the volume

sudo mkdir /mnt/ebs[ec2sudomount /dev/sdb1/mnt/ebs

11. Open the file on the EBS volume using a common text editor such as vim or nano /etc/fstab , and delete any instance store (ephemeral) volume entries. Because Amazon EBS volumes are installed /mnt/ebs on, fstab files are located /mnt/ebs/etc/fstab in the

[Ec2-user bundle]$sudonano/mnt/ebs/etc/Fstab#label=//Ext4 Defaults,noatime1   1Tmpfs/DEV/SHM TMPFS Defaults0   0devpts/dev/pts devpts gid=5, mode=620  0   0Sysfs/sys SYSFS Defaults0   0proc/PROC proc Defaults0   0/dev/sdb/media/ephemeral0 Auto Defaults,comment=cloudconfig0       2

In the example above, the last line should be deleted.

12. Unload and detach the volume from the instance

sudo umount /mnt/ebs[ec2-user bundle]$ ec2-detach-volume volume_id--region us-west-2  ATTACHMENT    volume_id    instance_id    /dev/sdb    detaching    - 24t23:+0000 

13. Create an AMI from your new Amazon EBS volume as shown below

A. Create a snapshot of the new Amazon EBS volume.

[Ec2-user bundle]$ ec2-create-snapshot--region us-west-2"your_snapshot_description  " -o $AWS _access_key-W $AWS _secret_key volume_idsnapshot    snapshot_id    volume_id    pending     - -25t00: +    1234567891011     Ten    your_snapshot_description

B. Check that the snapshot is complete.

[Ec2-user bundle]$ ec2-describe-snapshots--region us-west-2  snapshot_idsnapshot    snapshot_id    volume_id    completed    - -25t00:: +0000        1234567891011    ten    your_snapshot_description

C. Use the Ec2-describe-images command to determine the processor architecture, virtualization type, and kernel image (AKI) used on the original AMI. For this step, you need the AMI ID of the original AMI that the instance store supports.

[Ec2-user bundle]$ ec2-describe-images--region us-west-2 ami-IDIMAGE    ami-8ef297be    amazon/amzn-ami-pv-2013.09. 2. X86_64-S3    Amazon    available    public    x86_64    machine    aki-fc8f11cc    Instance-store    paravirtual    Xen

In this example, the schema is x86_64, and the kernel image ID is aki-fc8f11cc. Use these values in the following steps. If the output of the above command also lists the Ari ID, make a note of the ID.

D. Register the new AMI with the snapshot ID of the new Amazon EBS volume and the values obtained in the previous step. If the previous command output lists the Ari ID, include it in subsequent commands through--ramdisk ari_id.

[Ec2-user bundle]$ ec2-register--region us-west-2 -n your_new_ami_name-s snapshot_id--virtualization-type Hvm-a x86_64--kernel aki-fc8f11ccimage    new-ami-ID

14. (optional) After you have tested that you can launch an instance from the new AMI, you can delete the Amazon EBS volume that was created for this procedure.

$ ec2-delete-volume volume_id

See also:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html

Convert instance store support for EBS-backed Amis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.