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.
- Create an EBS volume in the same availability zone as your S3 instance running in.
- Attach the volume to running S3 instance as /dev/sdh
- Format the EBS volume as an ext3 file system. (Accepting defaults at the prompts should do).
- Turn off automatic file system checking:
tune2fs -c 0 /dev/sdh
- Create a mount point and mount the EBS volume
mkdir /ebs mount /dev/sdh /ebs
- Shut down currently running databases and other apps
- Synchronise your OS with the EBS file system using rsync
rsync -avx --exclude /ebs / /ebs
- Umount the mount point
- Snapshot the EBS volume (make sure snapshot is finished before proceeding).
- Make a note of AKI and ARI names of running S3 instance (you can find these in the instance details).
- 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.