My previous article on the subject of adding a swap file to an Amazon EC2 instance focused on adding the swap file to the instance storage (also known as ephemeral storage) that comes with certain Amazon EC2 instances. This article discusses how you can still leverage the concept of swap files even on “EBS only” Amazon EC2 instances.
Amazon Web Services (AWS) makes it very easy to expand EBS volumes. You just right-click on the volume, select modify, and enter the new, larger volume size. Done. To shrink Amazon EBS volumes, however, is a whole different matter – there is no way to do this directly using the AWS console. In this article, I describe a roundabout technique that I have often used to save some bucks in scenarios where I mistakenly over-allocated Amazon EBS when setting up EC2.