# Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

# Set up a Linux swap area:
mkswap /swapfile1

# Activate /swapfile1 swap space immediately:
swapon /swapfile1

# To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using a text editor such as vi:
vi /etc/fstab

# Append the following line:
/swapfile1 swap swap defaults 0 0