Convert an AWS instance-store AMI to an EBS backed AMI
Borrowed this from a site I had to pull up via Google's cache with some additions.
I recently needed to convert an AWS instance-store AMI to an EBS backed AMI. Here’s the steps I took in order to fix that. It’s a ext3 file system in this example, but it should work fine with an ext4 as well.
-
Launch your instance-store AMI
-
Create a new EBS in the same availability zone
-
Attach the EBS to the instance-store instance on
/dev/sdh
-
Create the file system
If you're trying to decide which filesystem to use:
Phoronix Comparison of FileSystems. tl;dr version:- NILFS2 has better random read performance
- EXT3 has better multi threaded read performance
- EXT4 has better overall performance.
mkfs.ext3 /dev/sdh
- Mount the device
mkdir /mnt/ebs
mount /dev/sdh /mnt/ebs
- Shut down any running applications or databases that you have and
rsync
your system to the EBS volume
rsync -avHx / /mnt/ebs
rsync -avHx /dev /mnt/ebs
- Label the device
tune2fs -L '/' /dev/sdh
- Sync and unmount the device
sync;sync;sync;sync && umount /mnt/ebs
- In the AWS Console, make a snapshot of the EBS drive
- Make a note of the AKI and ARI of the currently running instance (skip this if none are set)
- When the snapshot is complete, right click on it and choose "Create Image from Snapshot"
- Use the wizard to set an name and description of your new AMI. Also choose the right AKI etc.
- You should now be able to start a new instance from the newly created AMI.