Create a file for swap
======================
Create a file named /swapfile for 4GB size (e.g. Create a file called swapfile under root (/))
$ dd if=/dev/zero of=/swapfile bs=1024K count=4096
Format the swapfile with a mkswap command
======================================
$ mkswap /swapfile
Add the swapfile to swap
===========================
$ swapon /swapfile
Confirm if the swapfile is added
===========================
$ swapon -s
Filename Type Size Used Priority
/swapfile file 4194300 0 -1
Set up /etc/fastab to add swapfile when booting the OS
======================================
$ vi /etc/fstab
#
LABEL=/ / ext4 defaults,noatime 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/swapfile /swapfile swap defaults 0 0