Showing posts with label Add Swap Space in AWS EC2 Centos or Linux AMI. Show all posts
Showing posts with label Add Swap Space in AWS EC2 Centos or Linux AMI. Show all posts

Thursday, December 12, 2019

Add Swap Space in AWS EC2 Centos or Linux AMI

Here are the steps to create swap space in AWS EC2 CentOS or Linux AMI

1. Create an EBS volume (ssd gp2) of the size you want for your swap space. Suppose it is 4G.
2. Attach the volume into your instance. Suppose attached mount point is /dev/xvdf
3. Now run
sudo mkswap /dev/xvdf

4. sudo swapon /dev/xvdf
5. Edit file /etc/fstab and add following line in /etc/fstab
/dev/xvdf none swap sw 0 0
6. Now you can verify the added swap space.
sudo swapon --show