• Create an EBS volume (if converting from an S3 backed AMI then create it as 10Gb in size)
  • Attach the EBS volume to your running instance
  • Stop running services that may be locking files, etc, such as MySQL

At this point, you're ready to copy the contents of your root drive onto the EBS volume. A couple of additional points here - it makes sense to stop any services possible to make the transfer as clean as possible. One of our readers has suggested an alternative approach to dd in the comments - i've included it here as an option for completeness.

Option 1: dd
  • Copy the root drive to the EBS volume - dd bs=65536 if=SOURCE of=TARGET. Replace SOURCE with the boot volume, e.g. /dev/sda1 and TARGET with the EBS volume, e.g. /dev/sdj
  • fsck TARGET
  • mkdir /migrate
  • mount TARGET /migrate
Option 2: rsync

I suspect with this route you'd need to exclude any directories used for mounting other volumes, otherwise your rsync will run out of space on the target device.

  • mkfs.ext3 TARGET
  • mount TARGET /migrate
  • rsync -ax --progress / /migrate
  • rm -rf /migrate/migrate
And then continue..
  • At this point, you can make any necessary modifications to the fstab to allow your EBS based AMI to boot - the file can be found in /migrate/etc/fstab
  • umount TARGET
  • Create a snapshot of the EBS volume
  • Register the snapshot as an AMI by running ec2-register -n NAME --architecture ARCH --block-device-mapping /dev/sda1=SNAPSHOT:SIZE:false. There are a number of options here - some of which you can set when starting the instance if you prefer. NAME is the name of the AMI, ARCH is the architecture (i386 or x86_64). The block device mapping paramaters set the EBS snapshot to use as the boot device, the second parameter sets the size to 15Gb and final parameter sets the delete-on-termination attribute to false.
  • Run an instance based on the newly registered AMI - if you've set the EBS volume size to anything greater then 10Gb then expand the filesystem to the size of the device.
  • More details, as usual, can be found in the command line reference.