March 3, 2017

How to Convert S3-backed (instance store) AMI to EBS-backed AMI

In one of the recent Amazon Deep Dive Workshop, we were handed a cheat sheet to turn a Linux S3 instance to EBS backed instance. This is one of the simplest process I have come across.

  1. Create an EBS volume in the same availability zone as your S3 instance running in.
  2. Attach the volume to running S3 instance as /dev/sdh
  3. Format the EBS volume as an ext3 file system. (Accepting defaults at the prompts should do).
    mkfs.ext3 /dev/sdh
  4. Turn off automatic file system checking:
    tune2fs -c 0 /dev/sdh
  5. Create a mount point and mount the EBS volume
    mkdir /ebs mount /dev/sdh /ebs
  6. Shut down currently running databases and other apps
  7. Synchronise your OS with the EBS file system using rsync
    rsync -avx --exclude /ebs / /ebs
  8. Umount the mount point
    umount /ebs
  9. Snapshot the EBS volume (make sure snapshot is finished before proceeding).
  10. Make a note of AKI and ARI names of running S3 instance (you can find these in the instance details).
  11. Register the newly created snapshot as a new AMI. Note the double quotes in the following command and replace some of the text with valid values.
    ec2-register -n "<AMI Manifest Name goes here>" -d "<Description goes here>" -a i386 -root-device-name "/dev/sda1" -b "/dev/sdb=ephemeral0" -b "/dev/sdc=ephemeral1" --kernel <AKI ID goes here> --ramdisk <ARI ID goes here> -s <SNAPSHOT ID GOES HERE>

Finally thanks to the Mike Culver and Andrew Gough @AWS for organising this wonderful workshop.

Related content

Amazon AWS EC2 changing instance type

Topics: Amazon, Amazon Web Services, Big data technology, Bioinformatics, Cloud, EBS, EC2, S3