Tuesday, November 11, 2014

amazon ec2 - Unable to boot a customized HVM AMI on EC2




I am trying to customize an existing Debian Jessie HVM AMI(ami-116d857a) and store it as my private AMI. Though the AMI creation process succeeds, I am unable to boot from it. The instance shows started but I am not able to connect via ssh and monitoring also shows ssh connectivity is not available. I see the same issue with any other HVM AMIs. The same procedure works perfectly if it is a PVM AMI.



Here's the procedure I follow




  • Boot from an available AMI.

  • Install additional packages from package manager.

  • Install npm modules.(nodejs and npm have been installed in the previous step)

  • Install all available system upgrades.

  • Download and unarchive ec2-ami-tools in /opt.


  • SCP private key and certificate to the instance.

  • Create image of the instance using the following command



    /opt/ec2-ami-tools-1.5.7/bin/ec2-bundle-vol -c /home/admin/cert.pem -k /home/admin/pk.pem -u $aws_account_id -p $image_prefix -B ami=sda,root=/dev/sda1 --batch --debug


  • Then upload it to an existing S3 Bucket



    /opt/ec2-ami-tools-1.5.7/bin/ec2-upload-bundle -b my-ami-images -m /mnt/$image_prefix.manifest.xml -a $access_key -s $access_secret --retry --de
    bug


  • And then finally register the AMI




    aws ec2 register-image --name $image_prefix --image-location my-ami-images/$image_prefix.manifest.xml --region us-east-1 --virtualization-type hvm --root-device-name /dev/xvda1




All of these steps go fine without any error and I can see the AMI listed in my account with root device as instance store and virtualization type as HVM.


Answer



Your current AMI-creation process is creating an S3-backed (instance store) AMI image. But your source AMI is an EBS-backed AMI. You need to use a different method to create your AMI which will create an EBS-backed AMI.



Instead of bundling your instance and registering the AMI, do the following:





  1. Stop your EC2 instance.

  2. Using the AWS Management Console, select your EC2 instance and from the Actions menu select "Create Image". This will create an EBS-backed AMI image.



More information about creating EBS-backed AMI images can be found here:



Creating an Amazon EBS-Backed Linux AMI | Amazon Elastic Compute Cloud


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...