Swap should take place on the Instance Storage (ephemeral) disk and not an EBS device. Swapping will cause a lot of IO and will increase cost on EBS. EBS is also slower than the Instance Store.
It will usually be mounted to /mnt but if not run
To then create a swap file on this device do the following for a 4GB swapfile
sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=4096
Make sure no other user can view the swap file
sudo chown root:root /mnt/swapfile
sudo chmod 600 /mnt/swapfile
Make and Flag as swap
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
Add/Make sure the following are in your /etc/fstab
/mnt/swapfile swap swap defaults 0 0
lastly enable swap
sudo swapon -a
swap should take place on the Instance Storage (ephemeral) disk and not an EBS device. Swapping will cause a lot of IO and will increase cost on EBS. EBS is also slower than the Instance Store.
It will usually be mounted to /mnt but if not run
To then create a swap file on this device do the following for a 4GB swapfile
sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=4096
Make sure no other user can view the swap file
sudo chown root:root /mnt/swapfile
sudo chmod 600 /mnt/swapfile
Make and Flag as swap
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
Add/Make sure the following are in your /etc/fstab
/mnt/swapfile swap swap defaults 0 0
lastly enable swap
sudo swapon -a