How to convert Instance store AMI to EBS-backed AMI

  1. Launch an instance from an instance store-backed AMI.
  2. Make a note of the ramdisk ID and kernel ID, the running instance is using
  3. Create a 10GiB Amazon EBS volume in the same Availability Zone as that of the newly-launched instance e.g. /dev/sdf
  4. Attach the volume to the running instance using either the AWS Management Console or the command line interface.
  5. Make sure all services are turned off like mysqld, nginx etc.
  6. Format the volume with a file system. Newer kernels use /dev/xvdf convention
  7. mkfs.ext3 /dev/xvdf
  8. Create a directory /mnt/ebs and mount the volume on it.
  9. mkdir /mnt/ebs
    mount /dev/xvdf /mnt/ebs
  10. Copy the data on the root storage device to the newly-attached volume.
  11. rsync -avx --exclude /mnt/ebs / /mnt/ebs
    [SPECIFIC TO UBUNTU]
  12. Edit /mnt/ebs/etc/fstab, /mnt/ebs/boot/grub/menu.lst and /mnt/ebs/boot/grub/grub.cfg and replace uses of LABEL=cloudimg-rootfs with /dev/xvda1
  13. Remove /dev/xvda2 and /dev/xvda3 specific instructions from /mnt/ebs/etc/fstab
  14. [SPECIFIC TO CENTOS]
  15. Edit /mnt/ebs/etc/fstab, /mnt/ebs/boot/grub/menu.lst and replace uses of LABEL=/ with /dev/xvde1.
  16. Remove /dev/xvde2 and /dev/xvde3 specific instructions from /mnt/ebs/etc/fstab
  17. Create the following devices within the /mnt/ebs
  18. MAKEDEV console
    MAKEDEV generic
    MAKEDEV zero
    MAKEDEV null
  19. Detach the volume from the instance.
  20. Create a snapshot of the volume.
  21. Register the snapshot of the volume as an AMI. While registering make sure the architecture correctly configured and the Kernel ID and Ramdisk ID should match the one taken a note of in Step 2. If the Ramdisk ID information is not available form the instance then leave it to Use Default.