The swap partition is the portion of the hard drive that linux uses as virtual memory when it runs out of physical memory. It's similar to the windows swap file only instead of using an actual file, linux uses a partition on the hard drive instead.
The partition size should typically be twice as much as the amount of memory that your computer has. So, for example, if your computer has 512Mb of ram, you should create a swap partition of at least 1024Mb.
Creating Extended Swap Partition of 2GB
First create a Partition of 2GB
#fdisk /dev/sda
Press p (Than Enter)-----To Show Partition
Press n (Than Enter)-----To create Partition
Than Enter in First Cylinder
Than type +2G in Last Cylinder
Then type t and Enter--------To give partition id of swap
Then type partition No. 6 and Enter(we assume that it is 6 partition)
Then type lvm id 82 and Enter
Then type w and Enter (To save the partition)
#reboot (Then reboot the system)
After reboot the system
#mkswap /dev/sda6--------Format swap partition with swap file system
#swapon –a /dev/sda6----To Activate swap partition
#swapon –s------------------Check swap partition
#mkdir /swap----------------Creating a /swap directory
#vim /etc/fstab---------------Mount swap partition in /swap directory
/dev/sda6 /swap swap defaults 0 0
:wq
#mount –a
#swapon –s-----------------To check swap partition
To Delete Extended Swap Partition
First delete mount entry of swap partition in /etc/fstab
#swapoff /dev/sda6
#fdisk /dev/sda
Press d (Than Enter)-----To delete a partition sda6
Press 6 (then Enter)-------To give partition No.
Press p (Then Enter)------To show Partition on sda harddisk
Press w(Then Enter)------To save & exit
#reboot-------To reboot the system
#swapon –s----To check swap partition