Normally the swap space partitioned twice of RAM space, for example if your system RAM space is 2048 MB swap space 1024*4 = 4096 MB or minimum swap memory partitioned
equal of RAM memory.

Check the RAM Memory total, used and free space by using free command,
-m specified that MB size as human read,


#  free -m

             total       used       free     shared    buffers     cached
Mem:          2006       1820        185          0         53        764
-/+ buffers/cache:       1002       1004
Swap:         1012         14        998

In my system 2GB RAM space but the Swap space is 1GB only, so I will increase Swap space upto 2GB.

The size of the swap file calculate in MB size and multiple by 1024 to determine the block size for 2GB  2048*1024=2097152. On the shell prompt can calculate the total count using “bc” command,

# bc

bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.

2048*1024
2097152

quit

The below command count being equal to the block size,

# dd if=/dev/zero of=/swapfile bs=1024 count=2097152

2097152+0 records in                                                                                                                                                             
2097152+0 records out                                                                                                                                                             
2147483648 bytes (2.1 GB) copied, 87.1816 s, 24.1 MB/s                                                                                                                                

Make swap file using below command,

# mkswap /swapfile

Setting up swapspace version 1, size = 2054140 KiB
no label, UUID=cc79c13d-ab21-4a64-89a6-54b4718184c1

To enable swap space
# swapon  /swapfile 

Now, check the memory space,

# free -m
             total       used       free     shared    buffers     cached
Mem:          2006       1820        185          0         53        764
-/+ buffers/cache:       1002       1004
Swap:         3060         14       3046

This is temporarily mapped the memory space, if you want to swap file available even after the reboot add the below line in the file system /etc/fstab

# vim /etc/fstab

/swapfile         swap            swap    defaults        0       0

:wq!

To find out swap area usage summary by device,

# swapon -s

or

# cat /proc/swaps