This is nothing but a summary of the following guide on how to add a swap volume to a running instance on AWS :
- link : AWS Volume management
By default instances started on AWS do not have allocated swap memory … but u should ALWAYS add a swap mem to your running instance to avoid lack of memory overhead!
- Check if you have any swap on your instance
- If none, create a volume and attach it to the instance (you will have to assign it a letter in the format ‘sdf’, ‘sdg’, … etc. The added volume will be mounted on ‘/dev/xvdf’, ‘/dev/xvdg’, … etc. Here the example is run on ‘sdg’ mounted on ‘/dev/xvdg’.
to check your device (example ‘/dev/xvdg’)
- format the device for swap using
sudo mkswap /dev/xvdg
sudo swapon /dev/xvdg
to see your swap created!
Modify your ‘/etc/fstab’ and add the following line
/dev/xdvg none swap sw 0 0
to make the mount of the device persistent.