Swap partition is same thing as pagefile.sys for Windows. When we are using more RAM than we have, pagefile is used to store that extra data from memory.
For this Linux use swap partition. While you install Linux distribution most installers suggest to make swap partition that is twice the size of your RAM.
This is uncommon on VPS because that is a waste of storage on small servers.
But we can create and activate swap partition:
# make sure we aren't using swap free -m # total used free shared buffers cached # Mem: 2048 357 1690 0 0 237 # -/+ buffers/cache: 119 1928 # Swap: 0 0 0
Swap: 0 0 0 that means we aren’t using any swap partition.
Lets create and activate swap as root user:
# 1GB swap dd if=/dev/zero of=/var/swap.fs bs=1M count=1024 chmod 600 /var/swap.fs mkswap /var/swap.fs swapon /var/swap.fs
Swap partition is use temporary, until we save information about it inside fstab:
#/etc/fstab /var/swap.fs none swap sw 0 0
Now we can enjoy swap even after reboot.