Convert Instance Store AMI to EBS AMI


The article explains a step by step procedure for converting an Instance-Store based AMI to EBS based AMI. This article being a step by step procdeure, you can't find much explantion for the commands used. Once you have read this article you will find this as an easy task. 😉

Following are some of my reasons for converting current ami's to ebs based ami.

  • Low boot time
  • Higher I/O performance
  • Start/Stop instance
  • upto one TB of disk space

Lets start by launching the instance-store ami. You can perform the below 3 steps using amazon web interface.

  1. Launch an Instance-store ami.

  2. Create a EBS volume. (50 GB)

  3. Mount the EBS volume to your instance as /dev/sdf

  4. Login to the new instance

  5. Shutdown all running process and clean up files and pacakges not required for you.

  6. Create a file system in new volume

mkfs.ext3 /dev/sdf

  1. Mount the vloume to directory

mount /dev/sdf /mnt

  1. Using rsync copy the files from / to /mnt

rsync -avHx / /mnt/

  1. Now sync /dev

rsync -avHx /dev /mnt

  1. Sync once again to flush all the pending write operations.

sync

  1. Unmount the volume

umount /mnt

  1. Now, create a snapshot of the EBS volume using amazon interface or your favourite ec2 client.

  2. Register the snapshot as an AMI using ec2-register command. You will require ec2 api tools. (Refer step16 of create custom ami post for downloading and installing api tools)

ec2-register -K key.pem -C cert.pem -n <name> -d "Description" -s <snapshot id> -a i386 –root-device-name /dev/sda1

Now you have learnt how to convert an instance to ebs based ami. It won't take more than 10 minutes to convert the instance.