SWAP space on EC2 on separate volume

It’s an extension of my previous article – how to create SWAP on EC2 instance.

This time, we are going to create separate volume.

We start with creating new Volume:

Make sure that your volume is in the same zone, as your instance:

Attach volume to your desired instance:

 

After attaching – don’t forget to note Device – /dev/sdf in our case…

 

Finally

 

sudo mkswap -f /dev/sdf
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=0d446dc1-bd25-4a51-92e0-44d80a343fb5

sudo swapon /dev/sdf

lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  16G  0 disk
└─xvda1 202:1    0  16G  0 part /
xvdf    202:80   0   4G  0 disk [SWAP]

works as a charm…

free -m
             total       used       free     shared    buffers     cached
Mem:           993        657        336         20         53        277
-/+ buffers/cache:        325        668
Swap:         5119          0       5119

make it permanent:

nano /etc/fstab
/dev/sdf	swap	swap	defaults	0	0