AWS EC2: How I Added Swap File


Here’s the way I added swap file in AWS EC2, t2.medium. At that time, I was using Jenkins in the computer, and Jenkins didn’t work because of less swap area.

Procedure

  1. Create a file for swapping. I created 4GB file.

  2. Format the file for swap.

  3. Change permission of the file.

  4. Enable swapping.

  5. Check swapping.

  6. Modify /etc/fstab for auto mounting.