If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses. Note access to swap is slower and to physical memory.

A dedicated partition (recommended), a swap file, or a combination can be defined as swap space. Some recommends twice of physical memory. Nowadays, physical memories in new computers are fairly large, my experience is, half of physical memory is sufficient.

Here to show how to create a file system and assign it as as swap space (virtual swap partition).

First, create a 1000M swap file (eg with 2GB physical memory):

sudo dd if=/dev/zero of=/swap_file bs=1M count=1000

You may adjust the file size as your desire. You can also put the swap_file in a different location if desired.