Friday, March 26, 2010

Preparing EC2 AMI for X

I'm taking a note for myself on how to prepare a Windows EC2 AMI for software X.

Prepare the installation volume.
  • Start (or use an existing) instance of Windows Server 2003 (c1.small seems to work).
  • Download compressed installation archive to system disk. Note: IE needs double the amount of space to download a file. It first saves a copy under Temporary Internet Files, then copies the file to destination. Use another browser where appropriate.
  • Create an EBS volume for the unpacked installation files, attach it, and initialize the file system.
  • Unpack installation files to the EBS volume; make necessary modifications.
  • Terminate the instance, since the system disk is tainted.
  • Make a snapshot of the installation volume if desired.
Prepare the AMI
  • Start a new instance of Windows Server 2003 using an Amazon base AMI.
  • Mount the installation volume.
  • Install the software.
  • Unmount the installation volume.
  • Do NOT defragment the system volume! See below.
  • Make necessary modification to the system (e.g. raise Terminal Server color depth limit to 32-bits).
  • Use EC2 Config utility, make the password reset on next boot, then let it use sysprep to shutdown the computer for imaging.
Use the EC2 console to make the AMI. Both the installation volume and its snapshot may be discarded after the AMI is made. Leave the AMI's system disk snapshot intact.

The reason we do this in two phases is to ensure that the file system for the instance we want to create an image suffers the least amount of modification, only those necessary to install the software in question. Since snapshots are incremental (they can refer to the snapshot of the base AMI system disk), this minimizes the size of the snapshot we make. If you defragment the system volume, the defragmentation could cause the volume to differ greatly from the original, hence the incremental snapshot would become much larger.

No comments: