adding more swap memory to ec2 - restarone/violet_rails GitHub Wiki

follow this tutorial: https://dev.to/hardiksondagar/how-to-use-aws-ebs-volume-as-a-swap-memory-5d15

# check volumes
lsblk

output:

loop0         7:0    0 55.5M  1 loop /snap/core18/1988
loop1         7:1    0 70.4M  1 loop /snap/lxd/19647
loop2         7:2    0 55.5M  1 loop /snap/core18/1997
loop3         7:3    0 31.1M  1 loop /snap/snapd/11036
loop4         7:4    0 32.3M  1 loop /snap/snapd/11588
loop5         7:5    0 33.3M  1 loop /snap/amazon-ssm-agent/3552
loop6         7:6    0 69.9M  1 loop /snap/lxd/19188
nvme0n1     259:0    0    8G  0 disk
└─nvme0n1p1 259:1    0    8G  0 part /
nvme1n1     259:2    0    2G  0 disk

point to the volume you want to use as swap

sudo mkswap /dev/nvme1n1

#enable swap

sudo swapon /dev/nvme1n1

open the swap config and make the swap persist between reboots

sudo nano /etc/fstab

add this line to the end of the file

/dev/nvme1n1 none swap sw 0 0

check swap space

sudo swapon --show